Android 上的 Titanium Mobile 视频播放器无法正常工作

发布于 2025-01-03 06:08:21 字数 751 浏览 4 评论 0原文

我正在尝试通过单击按钮来播放 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剪不断理还乱 2025-01-10 06:08:21

视频播放器未添加到窗口中。尝试:win.add(activeVideo);

The video player was not added to the window. Try: win.add(activeVideo);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文