opentok / opentok-windows-sdk-samples

Sample applications illustrating best practices using OpenTok Windows SDK
MIT License
9 stars 29 forks source link

How to clear <OpenTok:VideoRenderer> view in WPF? #49

Closed ntustzeus closed 1 year ago

ntustzeus commented 1 year ago

From example we know how to show the video stream

            Publisher = new Publisher.Builder(context)
            {
                Capturer = capturerDevices[0].CreateVideoCapturer(VideoCapturer.Resolution.High, VideoCapturer.FrameRate.Fps30),
                Renderer = PublisherVideo
            }.Build();

When I call Session?.Disconnect(), the publisher's view still working and suscriber's view stay in the last image.

I want to clear the publisher and suscriber's view to empty, how can I do it?

sergioturgil-vonage commented 1 year ago

Session.Disconnect does not stop/clear the publisher video. For that you need to call publisher.PublishVideo = true/false. Calling publisher.Dispose() would also do the trick but it might be a bit more than you're asking for. This will also clear the last image in the remote subscriber video. Have in mind that there use to be a bug here where last publisher image remained frozen when switching off video, but this has been fixed in latest versions (2.24.2 or higher, I believe).

Also, although you've already contemplated this scenario I'll add the following just in case. For a subscriber video the thing is a bit more complicated. If a subscriber disconnects from the session you don't normally want to clear the subscriber VideoRenderer with a black screen. You would normally remove the VideoRenderer completely for that subscriber. Check sample "SimpleMultiparty" to see how subscribers add added or removed when they connect/disconnect.

Please let me know if this doesn't answer your doubts.