-
22 Jan 2013 12:45 PM #1
Unanswered: Video play() method doesn't exist
Unanswered: Video play() method doesn't exist
Hi,
I have the following code:
When I click the Play button, I receive a JS error in the Chrome Inspector:Code:var videos = [ { xtype : 'video', width : 780, height : 439, url : "http://path/to/my/video.mp4", posterUrl: "http://path/to/my/poster.png" } ] var buttons = [ { xtype: 'button', text: "Play", listeners: { tap: function() { videos[0].play(); } } }, { xtype: 'button', text: "Pause", listeners: { tap: function() { videos[0].pause(); } } } ]
The video plays back fine, though, on my webpage.Uncaught TypeError: Object #<Object> has no method 'play'
When I echo out the properties/methods of the video, only "xtype", "width", "height", "url", and "posterUrl" are listed. Where is the "play" method, and how do I access it from the buttons?
Thanks.
-
22 Jan 2013 9:03 PM #2Sencha - Sales Team
- Join Date
- Mar 2007
- Location
- Melbourne, Australia (aka GMT+10)
- Posts
- 738
- Vote Rating
- 6
- Answers
- 10
You should also add a itemId:'myVideo' attribute to your config and use that to get a handle on your video:
Code:Ext.ComponentQuery.query('video [itemId=myVideo]')[0].play();Check out SenchaWorld.com for articles, screencasts, conference videos and more.
Sencha Technical Training : Asia Pacific Region
Code Validation : JSLint | JSONLint | JSONPLint
-
23 Jan 2013 2:01 PM #3
Thanks for the reply. This does not work, however.
Going back to my original code, I changed the button listeners to this:
, pressed the button, and saw this output in my Chrome Inspector console:Code:listeners: { tap: function() { console.log(videos[0]); videos[0].play(); } }
The call to videos[0] is not a problem at all, as it is returning the video. The problem is that the video apparently has no public play() method.Code:Object {xtype: "video", width: 780, height: 439, url: "http://path/to/my/video.mp4", posterUrl: "playbutton.jpg"…} Uncaught TypeError: Object #<Object> has no method 'play'
Any other suggestions?


Reply With Quote


