Android 上的 Titanium Mobile 视频播放器无法正常工作
我正在尝试通过单击按钮来播放 .mp4。我已经用不同的 SDK 对此进行了测试,结果如下:
1.7.5:按下按钮时黑屏 1.8.0.1& 1.8.1:什么也没发生
如果未注释,该事件将被注册为警报“测试”正在运行。下面是我的代码:
// Create main window
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
// Initialize the variable that will hold the playing video
var activeVideo;
// Create a play button
var button = Ti.UI.createButton({
title: 'Play Video',
});
// Add the button to the window
win.add(button);
// Listen for a 'click' on the button
button.addEventListener('click', function () {
// alert('Test');
// Create the media player
activeVideo = Ti.Media.createVideoPlayer({
url: 'video.mp4',
autoplay: true
});
});
// Open the window
win.open();
I'm trying to play a .mp4 by clicking a button. I've tested this with different SDK's, heres the results:
1.7.5: Black screen when pressing button
1.8.0.1 & 1.8.1: Nothing happens
The event is registered as the alert 'Test' is working if it is uncommented. Here's my code below:
// Create main window
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
// Initialize the variable that will hold the playing video
var activeVideo;
// Create a play button
var button = Ti.UI.createButton({
title: 'Play Video',
});
// Add the button to the window
win.add(button);
// Listen for a 'click' on the button
button.addEventListener('click', function () {
// alert('Test');
// Create the media player
activeVideo = Ti.Media.createVideoPlayer({
url: 'video.mp4',
autoplay: true
});
});
// Open the window
win.open();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
视频播放器未添加到窗口中。尝试:
win.add(activeVideo);
The video player was not added to the window. Try:
win.add(activeVideo);