IOS - How to swap streams between 2 vlc players

This forum is about all development around libVLC.
watermamal
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2019 11:25

IOS - How to swap streams between 2 vlc players

Postby watermamal » 19 Jul 2019 11:50

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?

sherington
Cone that earned his stripes
Cone that earned his stripes
Posts: 491
Joined: 10 Sep 2008 11:57
VLC version: master
Operating System: Linux

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

Postby sherington » 21 Jul 2019 09:29

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.

watermamal
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2019 11:25

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

Postby watermamal » 21 Jul 2019 15:55

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.

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

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

Postby mfkl » 22 Jul 2019 06:59

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)
https://mfkl.github.io

watermamal
New Cone
New Cone
Posts: 4
Joined: 19 Jul 2019 11:25

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

Postby watermamal » 22 Jul 2019 16:28

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.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 15 guests