-
26 Jul 2012 11:51 PM #1
Unanswered: Issue with audio "ended" event
Unanswered: Issue with audio "ended" event
Hi there,
i'm fairly new to sencha and need some help
i'm tryin' to build a topdocked audio player. i got a selectfield with my tracks listed from a store.
if i push the play button the audio is playing, and if i'm switching the audio, the sound is still going on - works fine - till yet. i'm using the ".play(), .toggle() and .updateUrl() " method.
in my controller i'm using the "ended" event on the audio to check if the audio file is ended and then get the actual index from my store to increase it by 1 to get the new audio to update the url and play the song.
but the "ended" event works only once! and i really dont no why... it's upsetting! maybe someone of you could help me to go on!
thanks!Code:config: { refs: { audioSelect: '#audioselect', audioFile: '#audioTpl', }, control: { audioSelect: { change: 'changeAudioFile' }, audioFile: { ended: 'updateAudioFile' }, }, changeAudioFile: function(newValue, oldValue, eOpts){ var audio = this.getAudioSelect(); var audioFile = this.getAudioFile(); var playText = this.getAudioPlayer().down('button').getText(); audioFile.updateUrl(oldValue); if (playText == 'Pause') { audioFile.play(); audioFile.create(); } }, updateAudioFile: function(time, eOpts){ var audio = this.getAudioSelect(); var audioFile = this.getAudioFile(); var file = audio.getValue(); var currentIndex = audio.getStore().findExact("src", file); var storeLength = audio.getStore().getCount(); if (currentIndex !== storeLength-1) { currentIndex++; } var newUrl = audio.getStore().getAt(currentIndex).get("src"); audio.setValue(newUrl); audioFile.play(); } });
-
30 Jul 2012 6:31 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,120
- Vote Rating
- 453
- Answers
- 3160
Aren't the arguments for the ended event the component and the time not just the time?
As a debugging step you can add a listener to the audio.media.dom for the ended event that the actual <audio> element.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
31 Jul 2012 1:51 AM #3
Rookie
Rookie
Hey!
Thanks for your reply. Oh...i passed the parameter (this, time) and got an error...so with your advice i renamed this in "element" and get infos about the element
first step done!
But what to do now? Have i to reset the Listener? and how to do this, if
thanks and best regards!
Fabian
-
31 Jul 2012 5:15 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,120
- Vote Rating
- 453
- Answers
- 3160
You can't use this as an argument, it will be the audio component.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote