Page 1 of 1

IOS - How to swap streams between 2 vlc players

Posted: 19 Jul 2019 11:50
by watermamal
I'm using Vlckit for IOS and I want to set up a page with several camera RTSP streams, 1 larger view with the main stream and a stream list to its side but when I click on a stream of that list it should swap the stream with the main one. Just like in the image below:
Image

I tried swapping both mediaPlayer objects, I tried swapping their drawables and I tried swapping their VLCMedia property to no success.
How would I go about doing this in a way which doesn't involve restarting the streams entirely because they take too long to start from scratch?

Re: IOS - How to swap streams between 2 vlc players

Posted: 21 Jul 2019 09:29
by sherington
All the streams are playing at the same time?

When I did something similar before, not using VLCKit, I wrote a custom layout that let me "focus" one of the streams. The custom layout changed the position and size of the various player panes without doing anything related to the media player itself. So the streams were never stopped/swapped or whatever, it was purely that the UI components were shifted around.

Re: IOS - How to swap streams between 2 vlc players

Posted: 21 Jul 2019 15:55
by watermamal
Yes the streams are all supposed to be playing simultaneously.

I thought about that too but the Main Video stream is a subview of a UIScrollingView, which I use to allow the video to be zoomed in with a pinch gesture, and the list o the right side would be in a different scroll view so I can list more than 3 videos. So I would be much easier for me if I could swap the media displaying in the players or at least the object to which the players are drawing.

Re: IOS - How to swap streams between 2 vlc players

Posted: 22 Jul 2019 06:59
by mfkl
Use multiple UIView and multiple media players. It's doable, I wrote about this before https://mfkl.github.io/libvlc/rtsp/xamarin/forms/2018/12/05/crossplatform-RTSP-mosaic-views-with-libvlcsharp.html (Xamarin-based sample)

Re: IOS - How to swap streams between 2 vlc players

Posted: 22 Jul 2019 16:28
by watermamal
I have set up 1 UIViewControllers and 1 media player for each stream but it still doesn't work

Code: Select all

@objc func swap() { let media = video2container.media video2container.media = video1container.media video1container.media = media }

Code: Select all

@objc func swap() { let tmp = video2container.mediaPlayer.drawable video2container.mediaPlayer.drawable = video1container.mediaPlayer.drawable video1container.mediaPlayer.drawable = tmp }
Neither of the above are working, even if I stop and start the stream, which I don't want to do.




Code: Select all

@objc func swap() { let tmp2 = video2container.frame video2container.frame = video1container.frame video1container.frame = tmp2 }
This works but I still would have to remove and add subviews to both scroll lists, so if someone knows a better way it would be much appreciated.