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 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,556
    Answers
    3932
    Vote Rating
    1272
      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! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  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,556
    Answers
    3932
    Vote Rating
    1272
      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! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

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
  •