Live Streams don´t stop downloading chunks after stop

Topics: Windows 10 UWP
Aug 4, 2015 at 11:29 AM
Edited Aug 4, 2015 at 11:29 AM
Hi there,
We´ve found this problem when we´re analyzing the network traffic using fiddler and seems like on Live Streams, the player keeps downloading new chunks indefinitely or way after the stop / setsource=null has been invoked:
http://1drv.ms/1M2hHr6

Here is a very simple test project to reproduce the issue:
http://1drv.ms/1M2hW5r
In this screenshot we pressed stop before the request 317.

Using the apple's HLS test stream, the strems get closed after a period of time, but using ours it keeps downloading until the app is closed, I can provide a test stream if needed but can´t share it publicly

Any idea?
Coordinator
Aug 4, 2015 at 1:25 PM
Edited Aug 4, 2015 at 1:25 PM
This would be an issue with the underlying MediaElement and not with Player Framework. I would suggest reproducing the issue with MediaElement (taking Player Framework out of the picture) and posting your issue via dev.windows.com:

https://dev.windows.com/en-us/community
Aug 4, 2015 at 1:27 PM
I´ll do it.
Thanks,
Mar 8 at 6:17 PM
@Jose_zattoo, did you discover any solution to this issue?
Mar 14 at 10:35 AM
it was a problem with the MediaElement but it should be fixed by now.
The workaround was to set up the source to null twice

player.Source = null;
player.Source = null;
Mar 14 at 2:19 PM
Thank you ;)
Aug 9 at 11:55 AM
@Jose_zattoo, have a new solution to solve this problem?

the workaround (set two times player source = null) not work for me :(
Aug 9 at 3:30 PM
With the anniversary update we have to use the mediaSource and not use the player.Source anymore.
       MediaSource mediaSource; //Needed so that it can be disposed.

        private void Load_Click(object sender, RoutedEventArgs e)
        {
            mediaSource = MediaSource.CreateFromUri(new Uri(LoadUri.Text));
            mediaElement.SetPlaybackSource(mediaSource);
        }
 
        private void Stop_Click(object sender, RoutedEventArgs e)
        {
            //Unbind from the player
            mediaElement.Stop();
            mediaElement.Source = null;
 
            //Clean up app handles (not required)
            adaptiveSource.ManifestReadyEvent -= mediaElement_ManifestReady;
            adaptiveSource.AdaptiveSourceStatusUpdatedEvent -= mediaElement_AdaptiveSourceStatusUpdated;
            adaptiveSource.AdaptiveSourceFailedEvent -= mediaElement_AdaptiveSourceFailed;
            adaptiveSource = null;
            adaptiveSourceStatusUpdate = null;
            manifestObject = null;
 
            //Clean up MediaSource
            //This is what triggers AdaptiveSourceManager_AdaptiveSourceClosedEvent and stops the downloads.
            mediaSource.Dispose();
            mediaSource = null;
        }
 
Unfortunately, using the player framework, the SetPlaybackSource is not available, so, what I did is inherit from the player to expose this method:
    public class MediaPlayer : Microsoft.PlayerFramework.MediaPlayer
    {
        private MediaExtensionManager extensions = new MediaExtensionManager();
        private PropertySet propertySet = new PropertySet();
        private IAdaptiveSourceManager adaptiveSourceManager;
        private AdaptiveSource adaptiveSource = null;        

        public MediaPlayer() : base()
        {            
            extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "text/xml", propertySet);
            extensions.RegisterByteStreamHandler("Microsoft.Media.AdaptiveStreaming.SmoothByteStreamHandler", ".ism", "application/vnd.ms-sstr+xml", propertySet);

            // Gets the default instance of AdaptiveSourceManager which manages Smooth 
            //Streaming media sources.
            adaptiveSourceManager = AdaptiveSourceManager.GetDefault();
            // Sets property key value to AdaptiveSourceManager default instance.
            // {A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}" must be hardcoded.
            propertySet["{A5CE1DE8-1D00-427B-ACEF-FB9A3C93DE2D}"] = adaptiveSourceManager;            
        }
        
        public void SetPlaybackSource(IMediaPlaybackSource source)
        {
            this.MediaElementElement.SetPlaybackSource(source);
        }
Aug 10 at 10:26 AM
Hi @Jose_zattoo, thanks for your reply.

I’m not using mediaElement but Media Player Framework (by CodePlex) instead.
<!-- Media Player -->
        <common:MediaPlayer x:Name="mediaPlayer" x:FieldModifier="public" Grid.RowSpan="2" ManipulationMode="TranslateX" ControlPanelTemplate="{StaticResource ControlPanelTemplate}"
                           Visibility="{Binding IsLoadingAsset, Converter={StaticResource BooleanToVisibilityConverterInverted}}"
                           AutoHide="True" AutoHideBehavior="AllowDuringPlaybackOnly" InteractiveDeactivationMode="All" AutoHideInterval="00:00:5.0"
                           IsVolumeVisible="True" IsPlayPauseVisible="True" IsFullScreenVisible="False" IsTimeElapsedVisible="False" IsTimeRemainingVisible="False">
            <mmppf:MediaPlayer.Plugins>
                <adaptive:AdaptivePlugin/>
                <mmppf:PlaylistPlugin/>
            </mmppf:MediaPlayer.Plugins>
        </common:MediaPlayer>
Do you know any issue that needs to be done with mediaElement, or is just a customization option?
Nevertheless, I try your solution, but unfortunately do not solve my problem. I believe my problem is related with sending stop commands while the player is in the opening state. For instance, if I pull three videos sequentially, but don’t let the first and second one coming to playing state (imagine a zapping scenario), I believe the stop commands are ignored and I can see three streams getting consumed simultaneously.

Thanks in advance
Aug 10 at 10:33 AM
I do also use the player framework. The only way that i found to stop downloading chunks is to dispose the MediaSource, everything else didn't work, including stop or close the player.