This project has moved. For the latest updates, please go here.

AAC stream url doesn't play stream

Sep 5, 2014 at 2:49 PM
Edited Sep 5, 2014 at 2:50 PM
Why does this AAC stream not work? I'm using BackgroundAudio.Sample.WP8

var track = new AudioTrack(null, "Veronica", null, null, null, "http://8573.live.streamtheworld.com:80/VERONICAAAC_SC", EnabledPlayerControls.All);

Do I programmatically have to tell it's an AAC stream and not MP3?
Coordinator
Sep 5, 2014 at 8:08 PM
I didn't have any trouble playing the stream (well, minus not understanding what they were saying). It could be that the HEAD used to get the content type immediately followed by the GET to actually start playing the stream is causing trouble. Some servers are built to discourage misbehaving clients from hammering them by rate limiting connections. Anyhow, if you need to force the thing to be treated as an AAC stream, you can do so in AudioTrackStreamer.OnBeginStreaming(). Set the content type right after the InitializeMediaStream() call:
   InitializeMediaStream();

   _mediaStreamFacade.ContentType = ContentTypes.Aac;

   var mss = await _mediaStreamFacade.CreateMediaStreamSourceAsync(url, CancellationToken.None).ConfigureAwait(false);

   if (null == mss)
If nothing else, it will save an extra "HEAD" call for streams where the content type cannot be deduced from the URL. If you have multiple streams of different types, you may need to do something more complicated (set _mediaStreamFacade.ContentType to null to restore the default behavior).
Sep 8, 2014 at 8:24 AM
On AudioTrackStreamer.cs I see this:
    void InitializeMediaStream(AudioStreamer streamer)
    {
        if (null != _mediaStreamFascade)
            return;

        _mediaStreamFascade = MediaStreamFascadeSettings.Parameters.Create(_httpClients, mss => SetSourceAsync(mss, streamer));

        _mediaStreamFascade.SetParameter(_bufferingPolicy);

        _mediaStreamFascade.SetParameter(_mediaManagerParameters);

        _mediaStreamFascade.StateChange += TsMediaManagerOnStateChange;
    }
If I add:

_mediaStreamFacade.ContentType = ContentTypes.Aac;

I get the error in VS2013 that '_mediaStreamFacade' and 'ContentTypes' do not exist in the current context.

Also if I build BackroundAudio.Sample.WP8 there are 7 warnings:
Warning 1 Could not find SDK "Microsoft.PlayerFramework.WP8.Core, Version=1.8.2.2". SM.Media.MediaPlayer.WP8
Warning 2 Could not find SDK "Microsoft.PlayerFramework.WP8.Core, Version=1.8.2.2". SamplePlayer.WP8
Warning 3 Unreachable code detected C:\Users\Joost\Desktop\phonesm-1.2.2-source\Source\Libraries\SM.Media\MP3\Mp3StreamHandler.cs 44 17 SM.Media
Warning 4 The field 'SM.Media.CallbackReader._readerRunning' is assigned but its value is never used C:\Users\Joost\Desktop\phonesm-1.2.2-source\Source\Libraries\SM.Media\CallbackReader.cs 46 14 SM.Media
Warning 5 Field 'SM.Media.Mmreg.MpegLayer3WaveFormat.fdwFlags' is never assigned to, and will always have its default value 0 C:\Users\Joost\Desktop\phonesm-1.2.2-source\Source\Libraries\SM.Media\Mmreg\MpegLayer3WaveFormat.cs 60 21 SM.Media
Warning 6 The event 'SM.Media.Configuration.NullConfigurator.ConfigurationComplete' is never used C:\Users\Joost\Desktop\phonesm-1.2.2-source\Source\Libraries\SM.Media\Configuration\NullConfigurator.cs 60 35 SM.Media
Warning 7 Field 'SM.Media.Mmreg.MpegLayer3WaveFormat.nCodecDelay' is never assigned to, and will always have its default value 0 C:\Users\Joost\Desktop\phonesm-1.2.2-source\Source\Libraries\SM.Media\Mmreg\MpegLayer3WaveFormat.cs 62 23 SM.Media

Is that a problem?
Coordinator
Sep 8, 2014 at 9:17 AM
The assignment needs to be after the call to InitializeMediaStream(), not in the method body. The class "ContentTypes" is in SM.Media.Content, so you either need to add a using statement or to specify the whole name (SM.Media.Content.ContentTypes.Aac).

If you are not using the SM.Media.MediaPlayer.WP8 or SamplePlayer.WP8 projects and don't want to see those warnings, you can unload them (just right-click on those projects and hit "Unload Project").