3

How can I stop or pause a YouTube Video from playing when I go to another page

In Sencha Touch2 Here is my code it seems like it should work but Video still plays.

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&amp;hl=en_US&amp;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&amp;hl=en_US&amp;rel=0&autoplay=0" frameborder="0" allowfullscreen></iframe></div><img src="resources/images/thapelo3Fy.jpg" />');
}
});  
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
  • You can control YouTube videos in iframes with the Javascript Player Api. [Check out this link](http://apiblog.youtube.com/2011/01/introducing-javascript-player-api-for.html) – Titouan de Bailleul Jun 02 '12 at 09:46
  • My last post got voted down and deleted, but this new link should help and demonstrate the correct use of ExtgetCmp in Sencha Touch 2: http://stackoverflow.com/questions/11470957/ext-getcmp-not-working-on-hide-of-youtube-video-sencha-touch/11481878#11481878 – Digeridoopoo Jul 15 '12 at 11:35

1 Answers1

0

How can I stop a video with Javascript in Youtube? is what you need to do. Would have typed it here, but on my mobile...

Community
  • 1
  • 1
Jeff Wooden
  • 5,339
  • 2
  • 19
  • 24