Skip to main content

Microsoft Silverlight

Unanswered Question MediaElement BufferingProgressChanged gets stuck when connection is closedRSS Feed

(0)

EricSmith
EricSmith

Member

Member

141 points

34 Posts

MediaElement BufferingProgressChanged gets stuck when connection is closed

I'm working on a Silverlight application for viewing live video. There are two scenarios for how the video makes it from the source (a desktop application) to the Silverlight player: (1) relaying through a media server and (2) connecting directly to a port opened by the desktop application.

The playback works fine in either case, but there seems to be a problem (Silverlight bug?) in scenario 2 when the desktop app closes the connection on which it had been streaming video.Scenario 1 has the expected behavior:

  1. Establish a connection with the publishing point (by referencing an asx file if that matters)
  2. Video plays
  3. On the media server, stop the publishing point
  4. The Silverlight MediaElement's MediaEnded event fires

 

The unexpected behavior is:

  1. Establish a direct connection to the source application (also via an asx file)
  2. Video plays
  3. Close the connection from the source application (I don't know the exact details of the code here, but imagine if the application were simply closed)
  4. The Silverlight MediaElement's BufferingProgressChanged event fires
  5. BufferingProgressChanged event fires over and over, but the MediaElement's BufferingProgress property (after maybe a couple of events) remains exactly the same.   

I would have expected either a MediaEnded event or MediaFailed event.

I think I can work around the problem -- it is detectable by the repeated same value in BufferingProgressChanged, which the documentation says shouldn't happen -- but if I'm doing something fundamentally wrong I'd rather fix that. If it's a bug in Silverlight, hopefully Microsoft could fix it.

Thanks,

Eric

EricSmith
EricSmith

Member

Member

141 points

34 Posts

Re: MediaElement BufferingProgressChanged gets stuck when connection is closed

I've been digging into this a bit more and have some updates.

The problem I'm having can be replicated with Windows Media Encoder and a simple Silverlight application using a MediaElement:

  1. Set up a live broadcast in WME configured with the "Pull from the encoder" option.
  2. Start encoding.
  3. Set the MediaElement's Source to point at the URL where WME is broadcasting.
  4. Video plays in the Silverlight MediaElement.
  5. Stop encoding.
  6. The MediaElement's state changes to "buffering", and the BufferingProgressChanged event fires over and over while the BufferingProgress value stays constant.

Is the issue that Silverlight can't tell the difference between an ended stream and network interruption, and that it will patiently wait forever for the stream to reappear? Does Windows Media Server do something different so that the player gets a MediaEnded event instead?

I also tried the above experiment with the video player on CodePlex and saw the same behavior. After letting things sit for a while in the buffering state, I started up the encoder again. The video player played a few new frames, stopped playing for a bit, played some video really fast and finally stopped playing again (though the elapsed time continued to tick).

This turns out to be harder than I expected to work around since contrary to the BufferingProgressChanged documentation that says "The event will occur when the BufferingProgress value increases by 0.05 or more, compared to the last time the event was raised, and also when the value reaches 1.0", the event is actually raised many times when BufferingProgress remains the same. Maybe this is a difference between live and progressive download?

Anybody have any advice on this? I discovered another thread about this; a timer would be an unfortunate workaround.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities