• Resolved joelproko

    (@joelproko)


    Hi there
    I’m using the standalone version of the wordpress audio-player for a podcast we host on our website. The podcasters would like to know how many people listen to their episodes and I already managed to adress that for people coming in via RSS/iTunes.
    Now we’d also like to count how many people listen to the episodes via the audio-player. But apparently the player dislikes being given links to php-files that either redirect it to the mp3 or pretend to be the mp3.

    So I had the idea that I could introduce a quick GET-request in whichever function the audio-player’s javascript runs when you press the play-button on the player for the first time since loading the page, since that is basically the first time the mp3 is actually getting loaded.

    Does anyone happen to know which function that would be? I tried putting

    var counterlink = "../podcast/audioplayer_counter.php?file="+soundFile;
    var counter_http_request = new XMLHttpRequest();
    counter_http_request.open("GET", counterlink, true);
    counter_http_request.send(null);

    into the

    load: function (playerID, soundFile, titles, artists) {
    	getPlayer(playerID).load(soundFile, titles, artists);
    },

    part as well as into the activate part right above it. I even tried putting an alert(‘test’); in either function without anything happening. Firebug tells me that at least the activate function is called when you press the play button, but I can’t check what happens after that because Firefox immediately freezes completely whenever I put a breakpoint inside that activate function and it reaches that breakpoint.

    https://wordpress.org/plugins/audio-player/

Viewing 1 replies (of 1 total)
  • Thread Starter joelproko

    (@joelproko)

    Nevermind, the player will handle php scripts that redirect to the actual mp3 file just fine. You just have to urlencode stuff.
    In my case

    <script type="text/javascript">
        AudioPlayer.embed("audioplayer_1", {
            soundFile: "podcast/play.php<?php print(urlencode("?source=swf&file=".$_GET['audiofile'])); ?>",
            artists: "<?php print($_GET['audioautor']); ?>",
            titles: "<?php print($_GET['audiotitel']); ?>"
        });
    </script>

Viewing 1 replies (of 1 total)
  • The topic ‘call to counter script on load / first play’ is closed to new replies.