Support » Plugin: Audio Player » [Plugin: Audio Player] js listeners not working – addListener

  • This is a really great player but I’m having a problem interfacing to it with Javascript. The problem is I need to get Javascript notifications of play/pause/stop events and I can’t get them to work at all. I’m using the standalone player. For example, I’ve tried both of the methods below and the alert() is never called:

    AudioPlayer.addListener('audio-file-1877702', 'play', function(dat) { alert(dat); });

    p = AudioPlayer.getPlayer('audio-file-1877702');
    p.addListener('play', function(dat) { alert(dat); });

    This is a real problem since there are is an only for ‘play’ (activate) and ‘pause’ (onStop), but there isn’t one for ‘stop’, as shown in the source code. I’ve got to have the ‘stop’ event to resume a slideshow when a song finishes.

    Am I doing something wrong? Any help really appreciated!

Viewing 1 replies (of 1 total)
  • I would be interested in knowing your solution, if you ever found one. I also would like to be able to detect in Javascript play/pause/stop events. I am using the standalone player as well.

    When I try the following:
    AudioPlayer.addListener('my-id-1', 'play', function() { alert('testing'); });
    It always results in the following error in Firebug:
    getPlayer(playerID).addListener is not a function
    related to the following line of code:
    getPlayer(playerID).addListener(type, func);
    and this error in IE8:
    Object doesn't support this property or method

    From my various troubleshooting efforts, it appears to me that something is missing or coded wrong such that the functions in the Flash file that are supposed to be exposed (based on my examination of the source code you link to above) are not actually available, or if they are available this is not the correct code to access them.

    I even tried adding
    flashParams.allowscriptaccess = "sameDomain";
    to the embed function, thinking that maybe the flash file wasn’t allowing script access, but I still get the same error.

    Perhaps the creator of the code will chime in. 🙂

    If I could get the listener working I could then tie in Google Analytics events on my own, eg,
    AudioPlayer.addListener('my-id-1', 'play', function() { _gaq.push(['_trackEvent', 'Flash_Player', 'Play']); });
    which is something that I have been wanting to figure out how to do for some time.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: Audio Player] js listeners not working – addListener’ is closed to new replies.