Hi guys,
I am trying to have a Video Player instance inside a UICollectionVewCell but it is crashing.
My goal is to have at least 2 simultaneous RTSP Streams on screen on an iPad.
Is this even possible?
Thanks!
Here it is:It should be possible, yes. Do you have a lldb backtrace?
.[153c3274] avcodec decoder error: more than 5 seconds of late video -> dropping frame (computer too slow ?)
Hi Felix, I'm trying to do something similar and the videos are displaying as expected. However, there seems to be a bug where only one of the videos resizes on rotate. Can you confirm if your example has the same issues.In fact, this post reminded me of code I did in 2014. You can see a demo video here: https://vimeo.com/174839654
Code: Select all
public partial class VideoCollectionViewCell : UICollectionViewCell, IVLCMediaPlayerDelegate
{
VLCMediaPlayer mediaPlayer;
public VideoCollectionViewCell (IntPtr handle) : base (handle)
{
BackgroundView = new UIView { BackgroundColor = UIColor.Orange };
ContentView.BackgroundColor = UIColor.White;
mediaPlayer = new VLCMediaPlayer();
mediaPlayer.Delegate = this;
mediaPlayer.Drawable = ContentView;
mediaPlayer.Media = new VLCMedia(NSUrl.FromString("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"));
mediaPlayer.Play();
}
[Export("mediaPlayerStateChanged:")]
public void MediaPlayerStateChanged(Foundation.NSNotification notification)
{
Console.WriteLine("State changed to: {0}", mediaPlayer.GetState());
}
}
Code: Select all
public partial class VideoCollectionViewController : UICollectionViewController
{
List<string> videoUrls = new List<string>();
UICollectionViewFlowLayout FlowLayout;
public VideoCollectionViewController (IntPtr handle) : base (handle)
{
videoUrls.Add("");
videoUrls.Add("");
videoUrls.Add("");
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
FlowLayout = new UICollectionViewFlowLayout();
FlowLayout.MinimumLineSpacing = 0;
FlowLayout.MinimumInteritemSpacing = 0;
this.CollectionView.CollectionViewLayout = FlowLayout;
}
public override void ViewDidLayoutSubviews()
{
base.ViewDidLayoutSubviews();
var size = CalculateSize(); // function that returns size depending on screen orientation.
FlowLayout.ItemSize = size;
}
public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator)
{
base.ViewWillTransitionToSize(toSize, coordinator);
}
}
I am using autoayout.In fact, this post reminded me of code I did in 2014. You can see a demo video here: https://vimeo.com/174839654
if you are using it, here is how you do it:
Hi Felix, I'm trying to do something similar and the videos are displaying as expected. However, there seems to be a bug where only one of the videos resizes on rotate. Can you confirm if your example has the same issues.override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
self.collectionView.collectionViewLayout.invalidateLayout()
}
Relevant code (I'm using a Xamarin wrapper around MobileVLCKit, version 2.2.0 RC):Relevant controller code:Code: Select all
public partial class VideoCollectionViewCell : UICollectionViewCell, IVLCMediaPlayerDelegate { VLCMediaPlayer mediaPlayer; public VideoCollectionViewCell (IntPtr handle) : base (handle) { BackgroundView = new UIView { BackgroundColor = UIColor.Orange }; ContentView.BackgroundColor = UIColor.White; mediaPlayer = new VLCMediaPlayer(); mediaPlayer.Delegate = this; mediaPlayer.Drawable = ContentView; mediaPlayer.Media = new VLCMedia(NSUrl.FromString("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov")); mediaPlayer.Play(); } [Export("mediaPlayerStateChanged:")] public void MediaPlayerStateChanged(Foundation.NSNotification notification) { Console.WriteLine("State changed to: {0}", mediaPlayer.GetState()); } }
And the result:Code: Select all
public partial class VideoCollectionViewController : UICollectionViewController { List<string> videoUrls = new List<string>(); UICollectionViewFlowLayout FlowLayout; public VideoCollectionViewController (IntPtr handle) : base (handle) { videoUrls.Add(""); videoUrls.Add(""); videoUrls.Add(""); } public override void ViewDidLoad() { base.ViewDidLoad(); FlowLayout = new UICollectionViewFlowLayout(); FlowLayout.MinimumLineSpacing = 0; FlowLayout.MinimumInteritemSpacing = 0; this.CollectionView.CollectionViewLayout = FlowLayout; } public override void ViewDidLayoutSubviews() { base.ViewDidLayoutSubviews(); var size = CalculateSize(); // function that returns size depending on screen orientation. FlowLayout.ItemSize = size; } public override void ViewWillTransitionToSize(CGSize toSize, IUIViewControllerTransitionCoordinator coordinator) { base.ViewWillTransitionToSize(toSize, coordinator); } }
Portrait
Landscape (notice only 1 of the vids resized correctly)
Return to “VLC for iOS, iPadOS and Apple TV”
Users browsing this forum: No registered users and 39 guests