Issue playing M3U8 DRM playlist

Mar 7, 2014 at 9:06 PM
Hello!

I changed the m3u8 link from BackagroundAudio.Sample.WP8 with my m3u8 playlist link and it doesn't play and sound. This is the log file: music.log
Coordinator
Mar 7, 2014 at 9:31 PM
It looks like it isn't decrypting properly. Do you happen to know if the AES keys and IVs in the log file match what they should be? Does playing the unencrypted stream work (if you have it available)?

Do you happen to know if the audio format is detected correctly?
MPEG Version 1 (ISO/IEC 11172-3), Layer I sample 48kHz bitrate 128kHz channel mode 1
If you could get me a Fiddler2 trace (.saz file) or a zip of the .m3u8 and at least two or three segments (ideally, both the encrypted and decrypted segments), then I could take a look. Send a PM if you don't want to publish it here.
Coordinator
Mar 8, 2014 at 1:40 PM
Edited Mar 8, 2014 at 1:44 PM
The code that tries to guess what the segment contain can't do so from the URL, so it does a HEAD request and looks at the MIME type (the Content-Type header). The server responds with "audio/mpeg", which means the code thinks the segment is an MP3 file. However, it is actually an MPEG-2 Transport Stream.

If you can't change what the server returns or if you want to customize the detection code, you could add something like this:
    class TsWebContentTypeDetector : IWebContentTypeDetector
    {
        static readonly Task<ContentType> M3U8Result = Task.FromResult(ContentTypes.M3U8);
        static readonly Task<ContentType> TsResult = Task.FromResult(ContentTypes.TransportStream);

        #region IWebContentTypeDetector Members

        public Task<ContentType> GetContentTypeAsync(Uri url, CancellationToken cancellationToken)
        {
            if (url.AbsolutePath.EndsWith(".m3u8", StringComparison.CurrentCultureIgnoreCase))
                return M3U8Result;

            return TsResult;
        }

        #endregion
    }
And then set that as the IWebContentTypeDetector implementation. In the background audio sample, you would probably want to do so in AudioTrackStreamer.OnBeginStreaming():
    ...
            _mediaStreamFascade = MediaStreamFascadeSettings.Parameters.Create(_httpClients, mss => SetSourceAsync(mss, streamer));

            _mediaStreamFascade.Source = url;

            _mediaStreamFascade.Builder.RegisterSingleton<IWebContentTypeDetector, TsWebContentTypeDetector>();

            _mediaStreamFascade.SetParameter(_bufferingPolicy);

            _mediaStreamFascade.SetParameter(_mediaManagerParameters);

            _mediaStreamFascade.StateChange += TsMediaManagerOnOnStateChange;

            _mediaStreamFascade.Play();
    ...