在 Android 2.2 中使用 Titanium.Media.createVideoPlayer API 无法使用 Ti.UI.currentWindow 在 Titanium 2.1.2 中播放视频。
/**
* @author David
*/
var win = Ti.UI.currentWindow;
//var win = Ti.UI.createWindow({});
var contentURL = "http://assets.appcelerator.com.s3.amazonaws.com/video/media.m4v";
var openButton = Ti.UI.createButton({
title : "Start Video",
top : "0dp",
height : "40dp",
left : "10dp",
right : "10dp"
});
openButton.addEventListener('click', function() {
var activeMovie = Titanium.Media.createVideoPlayer({
url : contentURL,
backgroundColor : 'blue',
movieControlMode : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
fullscreen : true,
autoplay : true
});
var closeButton = Ti.UI.createButton({
title : "Exit Video",
top : "0dp",
height : "40dp",
left : "10dp",
right : "10dp"
});
closeButton.addEventListener('click', function() {
activeMovie.hide();
activeMovie.release();
activeMovie = null;
});
activeMovie.add(closeButton);
});
win.add(openButton);