"Now playing" display not in sync with streamed audio
  • My Airtime server is a cheap slow server, but is it that slow?

    The "Now playing" display in the airtime software is more than a minute faster than the audio stream itself. Can it be because the server takes so long to buffer the audio stream, or is there another reason that could maybe be fixed?

    The address of the stream is http://185.44.107.184:8000/ctradio

    You can listen to it via iTunes or Vox on Apple, or Winamp on Windows. Winamp changes the artist name / track name exactly in the moment when the track changes, so it can be done, but how? the Airtime software itself, and the widgets, change the "current" info a minute too early!  I wish the widget code could be changed to work like Winamp, but the jQuery programming is beyond me. My player uses the widgets and shows wrong data for "current" just as Airtime does: http://www.ct-collective.com/jplayer/jplayer.html

    If you want you can look at my Airtime at https://185.44.107.184 (log in as admin/admin - admin is set to "guest" and can't change anything)

    -Michael
    Post edited by Michael Peters at 2017-07-19 04:05:13
  • 29 Comments sorted by
  • It is more likely that there is a long buffer time set (or defaulted) in the player.
    So, if you play the station from the Listen button in Admin, is that a minute behind? A few, like 3 seconds, would be normal.
    No longer using Airtime or Libretime.
  • Three seconds would be absolutely no problem. Yes, Airtime itself is out of sync as well, that's what I was trying to describe. The Listen button player doesn't display titles but you can watch the moving status bar at the top of Airtime - it is already showing the next track while the old track still runs, for about 80 seconds.
    Please, if you have time, log in and take a look yourself, and maybe have an external player like Winamp so you can see the titles change in real time. Actually that is a second question - why can Winamp do something flawlessly that Airtime widgets can't? do they get artist/title directly from the audio stream?

    Post edited by Michael Peters at 2017-07-19 04:27:44
  • no idea?
  • It works perfectly here on 4 live radio stations.
    In the icecast status page - is that correct or lagging?
    Post edited by John Chewter at 2017-07-23 04:10:13
    No longer using Airtime or Libretime.
  • where can I see if it's correct or lagging? this is system/status, is this what you mean?

    You can also log in to my server with admin/admin and see how the progress bar lags behind the player.

    image
    Post edited by Michael Peters at 2017-07-21 13:55:35
  • No longer using Airtime or Libretime.
  • ah! 
    no, "current song" on the Icecast2 Status Window is correct, no lagging!
    What does that tell us?
  • It tells us that the Airtime system is working fine.

    So, the problem is in the handling of the JSON info, either the server is talking a long time to produce the JSON feed - unlikely if you are just using the now and next widget - OR, more likely, caching of the JSON in the player or server or both.

    1. If you have a cache on your server's hosting control panel, like Varnish, APC, or similar, try switching it off for a test.
    2. Disable any and all 'web browser accelerators' that you may have and test it in Firefox. Note: Chrome has VERY aggressive caching.
    3. If your player code has a buffering setting, typically 20 or more seconds by default, change it to 3 seconds,

    If it now works OK, you can narrow it down from there. There are tricks that can be put  in the player to defeat caching, like adding random numbers to the end of the string that fetches the JSON, Google that.

    OR

    Just use a widget or code snippet that gets its data from Icecast. This is what Winamp is doing. They are available for free. Google Icecast2 players.

    Post edited by John Chewter at 2017-07-23 04:26:38
    No longer using Airtime or Libretime.
  • > It tells us that the Airtime system is working fine.
    > So, the problem is in the handling of the JSON info

    Just to be sure you understand the problem - "lag" does not mean that the JSON data are displayed TOO LATE, it is that they display TOO EARLY. The JSON data of track #2 are already displayed while track #1 is still streaming, 80 seconds before #2 actually starts streaming.

    I will try to find out if the server has a cache ... just in case this is the problem.

    Otherwise, I don't use browser accelerators and I don't understand why that would make a difference. I tested this with three different browsers. My player and its buffering setting are also clearly not the problem. JSON caching on the client side can't be the problem. The lagging is not something that happens on my client machine, it happens on the server. It is showing inside of Airtime already. Have you taken a look at it?

    So before I spend days looking for another player again (I found no player so far that displays the metadata, so I ended up using jPlayer plus your JSON widget), do you think there is a way to make Airtime itself display the same track name that Icecast displays? does the Airtime frontend get these data from JSON? at this point, Airtime and the Icecast status page display different things.

    thanks -Michael

    Post edited by Michael Peters at 2017-07-23 12:44:22
  • A server cache will not make JSON turn up early.
    Some 'Go Faster Software' does indeed cache all browsers, but not make it early.
    It seems like JPlayer is buffering 80 seconds of streaming data. Do some players do this? Yes they do as it means that if the the network is slow and breaks momentarily the user does not notice.

    Have you tried using a straight forward plain-vanilla html5 audio player code snippet instead of JPlayer?
    That is what I use with a php randomizer on the end of the stream url. If you do not do this, when you come back to the page in 2 hours - you will get 20 minutes of the old previously played (cached) tracks.

    This minimal code works:

    <?php
    $mystreamurl='http://185.44.107.184:8000/ctradio'.'?'.time();
    ?>
    <audio controls>
        <source src="<?php echo $mystreamurl; ?>" type="audio/mpeg">
        Your browser does not support the audio element.
    </audio>

    If you say that will not work in IE6 and other ancient browsers more than 5 years old, I will scream.

    That code is working here: http://coastal-computing.com/ctplayer.php

    Post edited by John Chewter at 2017-07-24 03:38:07
    No longer using Airtime or Libretime.
  • Here is a script that claims to do what you need:
    https://www.radioforge.com/responsive-html5-radio-player/
    No longer using Airtime or Libretime.
  • https://www.muses.org/setup
    NOTE: This player is what Airtime Pro uses.
    No longer using Airtime or Libretime.
  • thx John.

    It seems that we have a communication problem.

    1. jPlayer is not buffering 80 seconds of incoming audio. The jPlayer audio is running at the same time that Winamp runs it, or any other player that I tried, including the "listen" player in airtime

    2. Your php player runs the audio just as good as jPlayer does but it doesn't display the current title, so it doesn't help

    3. "Here is a script that claims to do what you need" - no - it does not display the current title either - it just plays the audio just like my jPlayer.

    4. Why do you ignore that I wrote several times that the title display of _Airtime itself_ is 80 seconds ahead of the audio stream? wouldn't that give a clue to what is happening?

    5. Whatever the problem is, if I could find a jPlayer alternative that takes the icecast metadata _and displays them_, that would be a solution (actually just a workaround but good enough)

    best,  (and thank you for your help, really, I hope we'll eventually get there and then I won't bug you any longer)

    -Michael


  • I tried the Muses.org player a week ago already, and couldn't make it display the current title. Can you? what do you enter in the form then?  I think only the skins that have an [M] are supposed to display metadata but even those don't seem to

    stream URL is http://185.44.107.184:8000/ctradio
    Post edited by Michael Peters at 2017-07-24 05:32:32
  • I am just a happy hacker like you. I am not an employee of Sourcefabric. They never even respond anymore, and rarely did before.

    My idea, which seemed obvious to me, was to use the html5 code with the widget code. This is exactly what I do on several airtime stations and it works for me - no 80 second lag here.

    The old Muses works for me also - with track data. Now it only works with Icecast 2.4.0 when they added JSON to it.
    Post edited by John Chewter at 2017-07-24 13:16:15
    No longer using Airtime or Libretime.
  • http://coastal-computing.com/icecast/
    Try that. I wrote it for you.
    No longer using Airtime or Libretime.
  • wow, yes, that does work!  thanks so much! 

    Would you send me the sourcecode of iframe.php?  (to mp@mpeters.de unless you want to post it here) - then I could run it on my own server, but as I don't have PHP installed there, I'd try to rewrite it with ColdFusion (I'm a ColdFusion programmer and that's what's installed on the server), if it really contains dynamic code at all. Does it somehow extract the metadata directly out of the icecast stream? I'll have to look up what the stream consists of.

    And thanks for the clarification - all the time I thought you were, like, the official support person for Airtime, or even its author. Had I known that you're just a happy hacker like me, I'd have asked my questions in a different way.

    best,

    -Michael
    Post edited by Michael Peters at 2017-07-25 04:00:29
  • Yeah... I guessed. :(

    Don't have PHP installed? Its a 2 minute install.
    Sure, I will zip it all up tomorrow. I wanted to make sure it did what you wanted first.
    It scrapes the data from status.xsl
    It is in PHP & jQuery

    Post edited by John Chewter at 2017-07-25 20:06:12
    No longer using Airtime or Libretime.
  • Attached.
    No longer using Airtime or Libretime.
  • thanks bunches!
  • PHP and ColdFusion on same server.
    https://forums.adobe.com/thread/264915
    No longer using Airtime or Libretime.
  • Idea. There is no reason why you cannot put my player on your Airtime server and have an iframe in your ColdFusion Server.
    No longer using Airtime or Libretime.
  • update - no, of course PHP and Coldfusion can run on the same server, and indeed, PHP was already installed, contrary to what I thought (it is a shared server), however, it is only PHP 4.4.7 and half of the functions you use don't exist yet in that version. I have written to the provider, asking if he can update to 5.2. Or maybe I use another provider, that might also be possible. I'll keep you updated
  • 5.2 is insecure - ask for 5.6
    7.x is current.
    Post edited by John Chewter at 2017-07-27 06:15:26
    No longer using Airtime or Libretime.
  • I have it now running on another server with PHP 5.5.38-nmm3.

    http://veloopity.de/ct/radio/index.php

    At first, there was a permission denied error at file_put_contents so I changed the folder permissions to 777 and that error no longer appears.

    However, "current" doesn't show anything now.

    A json file was written containing this:
    {"info":{"status":"T0ZGIEFJUg=="}}  whatever that means.
    When I replace 'genre' by 'status' in iframe.php, it says 'off air' but the stream is streaming.

    Do I understand your code correctly - it reads and parses not the Icecast audio stream but simply the Icecast status page? why didn't I think of that! if we don't find an easy solution, I think I could also write something similar in Coldfusion.

    Post edited by Michael Peters at 2017-07-27 08:07:07
  • Yes, that is the trick
    My guess is file_put_contents & file_get_contents is not allowed and so it is not pulling the status.xsl content. Rewrite it with Curl or Wget. Hopefully one or other is allowed.
    Post edited by John Chewter at 2017-07-27 19:51:04
    No longer using Airtime or Libretime.
  • I rewrote it in Coldfusion. Because the rest of the CT site is written in Coldfusion, it was easy to also read track length, subtitle, and album cover from the database, and display them under the player.
    Thanks again, it wouldn't have been possible without your help.

    best, -Michael

    http://www.ct-collective.com/radio/index.cfm

  • I am just a regular Super-Hero
    See some more of us here: http://web-radio-support.websitesinternational.net/independent-web-radio-forum
    No longer using Airtime or Libretime.
  • I've also noticed this with LibreTime so I'm assuming the problem lies in the way Airtime pypo aka airtime-playout interacts with liquidsoap. There is also a wicked long buffer in the ALSA playout if you are using a soundcard to output your station. I think there is a buffer before it sends the audio to icecast as well which could result in the incorrect metadata being displayed.

    One thing I've seen happen  is that the web interface is updated but then airtime-playout tries to schedule the track and there is a delay before it actually clears off the old track or schedules the new one. It tends to download the tracks from the server and then schedule them with liquidsoap. There is funky stuff happening here, (especially with LibreTime where you can psuedo-live schedule tracks vs. Airtime 2.5.x which basically said if you schedule something and then want to change it after it starts you are out of luck.