开发者

Playing multiple Silverlight MediaElements at once

Here is the problem:

I have a Silverlight application where we would like to play 8 Silverlight MediaElements at once. All are playing .MP4 videos.

The first 6 will load almost immediately, and have the MediaOpened within a second or two. The remaining 2 will sometimes (not always) take minutes before playing / reporting that they are ready to play.

If I just play 6 or less, there seems to be no problem.

Here is what I've found:

1) There is no relation to the fil开发者_开发百科es. I can switch the order of the MediaElements and the first 6 I attempt to open will open just fine and the remaining will block.

2) There isn't necessarily a bandwidth issue (I tried compressing the files down to almost nothing and the same thing happened).

3) This isn't an IIS issue (my server), I don't think, since I've maxed out simultaneous connections.

4) My client machines are not pegged at all. The network is consistent at 25%, so it's possible the remaining 2 are being starved out there, but what's magic about the 7th and 8th?

Code

My code seems unimportant, but I will include it because people seem to like it when you do:

foreach ( String Uri in UriList )
{
   //For every URI we create a new MediaElement.  In our test case this is 8 always.
   MediaElement newMediaElement = new MediaElement();

   // We use MediaOpened as our 'ready to play' event.  Buffering remains at 0 for the 
   //  two streams that don't work.
   newMediaElement.MediaOpeened += new System.Windows.RoutedEventHandler(stream_MediaOpened);

   //Set the source and add it to some list to be added to a grid later...
   newMediaElement.Source = uri;       
   MediaElementList.Add( newMediaElement );
}

Following this the MediaElementList gets added to a Grid defined in XAML.

If people think more code will be helpful I'll add the specific parts. Like I said, I don't think the code will be useful, but you never know...

Other research

Other people have this problem, but we haven't found a solution. We've seen this and this and this, but none of them give any answer other than they don't know.

EDIT: Okay, so there's a limit of 6, as Kevev points out. Does anyone know of any way around this?


The Silverlight 4 HTTP networking stack is limited to 6 concurrent connections.

See here under the Client HTTP Processing section:

Concurrent connection limit is raised from 2 to 6

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜