1. #1
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    102
    Vote Rating
    0
    qbert65536 is on a distinguished road

      0  

    Default Audio tag

    Audio tag


    Is there a way to tell when the audio stops playing ? I'm trying to build a mp3 player and need to load the next song when the current one is finished.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    102
    Vote Rating
    0
    qbert65536 is on a distinguished road

      0  

    Default


    And how would I attach listeners for those ? Nothing I try seems to work.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    The underlying element of the component is the audio tag, so:

    Code:
    new Ext.Audio({
        listeners: {
            afterrender: function(c){
                c.el.on('.....');
            }
        }
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    102
    Vote Rating
    0
    qbert65536 is on a distinguished road

      0  

    Default


    Hmm, yes this is what I was trying, but using the above code I'm still not able to catch any events:

    Code:
                    new Ext.Audio({
                        url: 'crash.mp3',
                        listeners: {
                            afterrender: function(c) {
                                alert('rendered');
                                c.el.on('pause', function () { alert('paused') } );
                            }
                        }
                    })
    The rendered alert get's displayed, but the paused never happens . Is there a difference for listening for DOM events and Component events ? I'm using Chrome Beta 7.0.517.24 beta, is there another browser I should try it with ?

    I'm also not getting any errors or warnings, just nothing happening.

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,915
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Ah, wrong property:

    Code:
    Ext.setup({
        icon: 'icon.png',
        glossOnIcon: false,
        onReady: function(){        
            new Ext.Audio({
                url: 'crash.mp3',
                loop: true,
                showControls: true,
                listeners: {
                    afterrender: function(c){
                        c.media.on('play', function(){
                            alert('play');    
                        });
                    }
                }
            }).show();
            
        }
    });
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Ext JS Premium Member
    Join Date
    Jul 2009
    Posts
    102
    Vote Rating
    0
    qbert65536 is on a distinguished road

      0  

    Default


    Works thanks .

    This is twice this has happened actually, attaching listeners to the wrong class. How do I know which class to attach listeners to ?

  8. #8
    Touch Premium Member
    Join Date
    Nov 2011
    Posts
    12
    Vote Rating
    0
    william-wang is on a distinguished road

      0  

    Default audio tag

    audio tag


    What wrong property? What makes this work but previous code doesn't?

    Any change if we were to use the sencha touch 2 api?

    Quote Originally Posted by evant View Post
    Ah, wrong property:

    Code:
    Ext.setup({
        icon: 'icon.png',
        glossOnIcon: false,
        onReady: function(){        
            new Ext.Audio({
                url: 'crash.mp3',
                loop: true,
                showControls: true,
                listeners: {
                    afterrender: function(c){
                        c.media.on('play', function(){
                            alert('play');    
                        });
                    }
                }
            }).show();
            
        }
    });

Similar Threads

  1. [REFLOW] IFrames, Flash, Movies, Audio
    By hendricd in forum Ext 2.x: User Extensions and Plugins
    Replies: 9
    Last Post: 4 Mar 2012, 9:02 PM
  2. Play Audio without QT full screen
    By mediamacros in forum Sencha Touch 1.x: Discussion
    Replies: 7
    Last Post: 28 Nov 2010, 5:04 AM
  3. Multiple Audio items by AJAX
    By aron.duby in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 10 Sep 2010, 7:44 PM
  4. hidden Audio, pops up quicktime
    By russellharrower in forum Sencha Touch 1.x: Discussion
    Replies: 7
    Last Post: 2 Aug 2010, 12:12 AM
  5. How to capture audio in Extjs?
    By acinom in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 2 Apr 2009, 4:37 PM

Thread Participants: 2