This project has moved and is read-only. For the latest updates, please go here.

metadata from stream

Mar 15, 2015 at 5:17 PM
Back at this subject...

How about being able to grab metadata from the stream.. to show current artists .. wherever the stream holds..

Is it a enormous task?
Any leads?
Coordinator
Mar 15, 2015 at 6:36 PM
I have local changes for both WP7/8 and WP8.1 background audio that updates the title (both in the main UI and in the System Media Transport Controls) from the simple, inline Shoutcast metadata (the "StreamTitle=Xyz" stuff). There are some things that need to be fixed before I can push the changes; that should hopefully happen within the next couple of days.

Is there some particular type of metadata encoding you are looking to support?
Mar 15, 2015 at 9:22 PM
That would be perfect for the Windows Phone Application (Universal)

Maybe an event to raise the change so on MVVM we could wire it to a INotifiyProperty ...

I don't use the background audio directly because I need to be able to switch between the SDK supported formats and the ones from phonesm.
Coordinator
Mar 15, 2015 at 9:43 PM
Well, you can take a look at the changes I just pushed. WP8.1's Background audio manages to update the UI some of the time (still working on it). The two key points are to request metadata from the server:
        static readonly IWebReaderManagerParameters WebReaderManagerParameters
            = new WebReaderManagerParameters
            {
                DefaultHeaders = new[] { new KeyValuePair<string, string>("icy-metadata", "1") }
            };
   ...
            _mediaStreamFacade = MediaStreamFacadeSettings.Parameters.Create();

            _mediaStreamFacade.SetParameter(WebReaderManagerParameters);
and to provide something that listens for the changes like MetadataHandler does for WP8.1's background audio. You just need something that implements IMetadataSink and registers with the DI container (generally, through "_mediaStreamFacade.SetParameter()"). Note that blocking in any of the IMetadataSink handlers is probably a bad idea, so store the data somewhere and notify the UI asynchronously. Oh, and note the timestamps that come along with the metadata. One will generally get the metadata a bit before it is current, so compare the metadata timestamp with the current position to determine when something should be displayed (I think this part is what is broken on WP8.1's background audio).
May 1, 2015 at 11:50 PM
I have the Background Audio app running on my phone, but I don't see the code mentioned above (in AudioTrackStreamer) getting hit. Is this currently wired up?

Thanks!
Coordinator
May 2, 2015 at 6:18 AM
This should be working with both WP8 and WP8.1 background audio. It should be relatively straight-forward to implement it for the other sample apps as well, but I have not yet done so.

Which version of the code are you using? Are you sure the stream you are playing provides the "StreamTitle=" type of metadata? I picked some random station off of http://dir.xiph.org/ and they are providing metadata. Could you give http://server142.radiochoice.net:8080/1014_a0mixfm64k or http://streaming203.radionomy.com/J-PopProjectRadio a try?

IIRC, there might be a problem where the first track metadata update can get delayed.

I've wasted far too much time lately trying to find ways to work around WP8.1 background audio's brain damage (besides the memory leak, it also can get into a state were property reads never return, re-syncing the foreground and background after a failure is tricky, and the first time one uses Visual Studio's Lifecycle Events -> Suspend often pauses playback without actually updating the player's CurrentStatus to that effect). The WP8 background audio actually works, but now I don't remember the exact state of affairs there.