【发布时间】:2012-06-02 06:56:40
【问题描述】:
当我转到另一个页面时,如何停止或暂停 YouTube 视频的播放
在 Sencha Touch2 这是我的代码,它似乎应该可以工作,但视频仍然可以播放。
Ext.define('MyApp.view.tablet.Home5', {
extend: 'Ext.Panel',
xtype: 'home5',
config: {
scrollable: true,
cls:'logo',
items:[
{
xtype: 'panel',
id: 'videopanel',
html:[
'<div id="video1"><iframe width="560" height="315" src="http://www.youtube.com/embed/NSUucup09Hc?fs=1&hl=en_US&rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div>',
'<img src="resources/images/thapelo3Fy.jpg" />'
].join("")
}
]
},
hide: function(container, options){
this.callParent(arguments);
//workaround to stop the video (= reset the html)
Ext.getCmp('videopanel').setHtml("");
Ext.getCmp('videopanel').setHtml('<div id="video1"><iframe width="560" height="315" src="http://www.youtube.com/embed/NSUucup09Hc?fs=1&hl=en_US&rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div><img src="resources/images/thapelo3Fy.jpg" />');
}
});
【问题讨论】:
-
您可以使用 Javascript Player Api 在 iframe 中控制 YouTube 视频。 Check out this link
-
我的上一篇文章被否决并删除了,但这个新链接应该有助于并展示在 Sencha Touch 2 中正确使用 ExtgetCmp:stackoverflow.com/questions/11470957/…