Results 1 to 4 of 4

Thread: Issue with audio "ended" event

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default 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!

    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();
        }
    
    });
    thanks!

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,323
    Answers
    3883
    Vote Rating
    1293
      0  

    Default

    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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jul 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default 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

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,323
    Answers
    3883
    Vote Rating
    1293
      0  

    Default

    You can't use this as an argument, it will be the audio component.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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 in print!

    When posting code, please use BBCode's CODE tags.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •