locked
PlayTo for multiple videos RRS feed

  • Question

  • I'm am trying to use the PlayTo connection to play several videos in a row to a PlayTo device.  Ideally, what I want to happen is that

    Step 1:  the user starts the first video

    Step 2: the user selects the device to PlayTo and the video begins streaming

    Step 3: while the current video is playing, the user decides to play a different video and selects that. 

    THE HARD PART:  The uses does NOT have to disconnect the first video, play the second, and then reconnect.  I want to be able to use the PlayToSource.Next and PlayNext() functions.  The available sample shows how to do this with a slideshow using images.  The biggest problem for me is that using a mediaelement complicates things.  I cannot connect the first (and permanent) mediaelement to the playtosource unless there is a video already open and playing.  Ok, that's not a big problem... however, I can't figure out how to connect the next video and get it working correctly. 

    (I think) I have to:

    1. create a new mediaelement

    2. load the video

    3. wait for the mediaopened event

    4. set the original_mediaelement.PlayToSource.Next = new_mediaelement.PlayToSource.

    5. call original_mediaelement.PlayToSource.PlayNext()

    This causes some really weird problems.  In one of my code iterations, the original_video tends to show up back on the original device and resume playing there. 

    Is the original_mediaelement the container for the new video now?  Or is the new_mediaelement still the container?  So if the original video was playing and I called original_mediaelement.Stop(), would it stop the local playback or would it also stop the PlayTo playback? 

    As you can see, this is confusing me quite a bit.  I'd appreciate a little guidance.  Thanks!


    Lee McPherson

    Monday, November 12, 2012 5:11 PM

Answers

  • Hello,

    Q. Is the original_mediaelement the container for the new video now?

    A. "Original" is still connected to the PlayTo client.

    Q. So if the original video was playing and I called original_mediaelement.Stop(), would it stop the local playback or would it also stop the PlayTo playback?

    A. Calling "stop" on the ME that is acting as the PlayTo Source should have the effect of stopping the playback of the PlayTo client. However, I've heard reports that this is not always the case. Some DLNA clients require that the client stop playback.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, November 15, 2012 1:48 AM
    Moderator

All replies

  • Hello,

    Q. Is the original_mediaelement the container for the new video now?

    A. "Original" is still connected to the PlayTo client.

    Q. So if the original video was playing and I called original_mediaelement.Stop(), would it stop the local playback or would it also stop the PlayTo playback?

    A. Calling "stop" on the ME that is acting as the PlayTo Source should have the effect of stopping the playback of the PlayTo client. However, I've heard reports that this is not always the case. Some DLNA clients require that the client stop playback.

    I hope this helps,

    James


    Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, November 15, 2012 1:48 AM
    Moderator
  • Yes, this helps quite a bit.  In fact, it made me realize that something was intrinsically wrong with how my app creates and manages mediaelements.  I decided to rewrite everything, including the DataModel.  Lo and behold, PlayTo works PERFECTLY.  The really crazy part is that it works without any PlayTo specific code whatsoever in my app.  I'm talking nothing but logic to get the MediaElement playing video locally.  As the video is playing, when I hit the Devices button, MediaPlayer on my 2nd computer is there waiting to receive data.  The video switches over just fine.  When I select a different video to play within the app, it starts playing on the remote computer. 

    I don't get it.  It works perfectly.  I didn't need a PlayToManager.  So I didn't need to handle the SourceRequested event.  I didn't need to use PlayToSource for the mediaElement at all. 

    Now I'm more confused.  But if this keeps working, I'm not going to change anything.


    Lee McPherson

    Monday, November 19, 2012 4:45 AM