VLCKit mediaPlayerStateChanged error in IOS - Swift

iOS, iPad, iPhone, tvOS specific usage questions
ssaguiar
Blank Cone
Blank Cone
Posts: 28
Joined: 06 May 2009 22:35

VLCKit mediaPlayerStateChanged error in IOS - Swift

Postby ssaguiar » 06 Jul 2016 22:08

I wish to know if somebody can help in this problem.

I am working in one app to play hls streams.
The problem is that the mediaPlayerStateChanged event is fired but the event is allways 2.

This is the code I am using:

Code: Select all

class AVideoPlayerViewController: UIViewController, VLCMediaPlayerDelegate { . . . func mediaPlayerStateChanged(aNotification: NSNotification!) { let currentState: VLCMediaPlayerState = mediaPlayer.state(); switch(currentState) { case 2: print("mediaPlayerStateChanged -> 2..."); ActivityIndicator.stopAnimating(); ActivityIndicator.hidden = true; break; case VLCMediaPlayerStateError: print("mediaPlayerStateChanged -> Error!"); break; case VLCMediaPlayerStateEnded: print("mediaPlayerStateChanged -> Ended!"); break; case VLCMediaPlayerStateStopped: print("mediaPlayerStateChanged -> Stopped!"); break; case VLCMediaPlayerStateBuffering: print("mediaPlayerStateChanged -> Buffering..."); ActivityIndicator.startAnimating(); ActivityIndicator.hidden = false; break; case VLCMediaPlayerStateOpening: print("mediaPlayerStateChanged -> Opening..."); break; case VLCMediaPlayerStatePaused: print("mediaPlayerStateChanged -> Paused..."); break; case VLCMediaPlayerStatePlaying: print("mediaPlayerStateChanged -> Playing..."); ActivityIndicator.stopAnimating(); ActivityIndicator.hidden = true; break; default: break; } print("VLC STATE -> \(mediaPlayer.state())") }
As I said, the state wich is fired is allways 2 and the others are not being fired.

I have followed the code in the examples of vlckit (specially DropIn-Player).

Thanks for any help

Sergio
Last edited by ssaguiar on 07 Jul 2016 16:00, edited 1 time in total.

ssaguiar
Blank Cone
Blank Cone
Posts: 28
Joined: 06 May 2009 22:35

Re: VLCKit mediaPlayerStateChanged error in IOS - Swift

Postby ssaguiar » 07 Jul 2016 15:11

In reality, it seem that the states are being fired but the playing state (VLCMediaPlayerStatePlaying).
I start to play the stream and get the bufferin state (VLCMediaPlayerStateBuffering).
If I pause the player I get the pause state (VLCMediaPlayerStatePaused).
After entering the pause, I get the playing state (VLCMediaPlayerStatePlaying), but this state is not being fired after the buffering one, when the stream start playing.

Because of this the ActivityIndicator is allways showing.

This is the code I am using:

Code: Select all

override func viewDidLoad() { super.viewDidLoad(); print("AVideoPlayerViewController -> viewDidLoad"); ActivityIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.White; ActivityIndicator.center = view.center; ActivityIndicator.startAnimating(); url = self.channelsingleton.url; print ("AVideoPlayerViewController URL: \(url)"); //Add rotation observer NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(AVideoPlayerViewController.rotated), name: UIDeviceOrientationDidChangeNotification, object: nil); MovieView.frame = UIScreen.screens()[0].bounds; //Add tap gesture to movieView let gesture = UITapGestureRecognizer(target: self, action: #selector(AVideoPlayerViewController.movieViewTapped(_:))); let gesture2 = UITapGestureRecognizer(target: self, action: #selector(AVideoPlayerViewController.movieViewTapped(_:))); self.MovieView.addGestureRecognizer(gesture); self.MainControls.addGestureRecognizer(gesture2); let media = VLCMedia(URL: url); mediaPlayer.setMedia(media); mediaPlayer.setDelegate(self); mediaPlayer.drawable = self.MovieView; mediaPlayer.play(); self.timerPlayer = NSTimer.scheduledTimerWithTimeInterval(4.0, target: self, selector: #selector(AVideoPlayerViewController.playertick), userInfo: nil, repeats: false); } . . . func mediaPlayerStateChanged(aNotification: NSNotification!) { let currentState: VLCMediaPlayerState = mediaPlayer.state(); print("AVideoPlayerViewController -> mediaPlayerStateChanged - state: \(currentState)"); switch(currentState) { case VLCMediaPlayerStateStopped: //< Player has stopped print("mediaPlayerStateChanged -> Stopped!"); break; case VLCMediaPlayerStateOpening: //< Stream is opening print("mediaPlayerStateChanged -> Opening..."); break; case VLCMediaPlayerStateBuffering: //< Stream is buffering print("mediaPlayerStateChanged -> Buffering..."); ActivityIndicator.startAnimating(); ActivityIndicator.hidden = false; break; case VLCMediaPlayerStateEnded: //< Stream has ended print("mediaPlayerStateChanged -> Ended!"); break; case VLCMediaPlayerStateError: //< Player has generated an error print("mediaPlayerStateChanged -> Error!"); break; case VLCMediaPlayerStatePlaying: //< Stream is playing print("mediaPlayerStateChanged -> Playing..."); ActivityIndicator.stopAnimating(); ActivityIndicator.hidden = true; break; case VLCMediaPlayerStatePaused: //< Stream is paused print("mediaPlayerStateChanged -> Paused..."); break; default: break; } }
The
Anybody has any idea?

Thanks


Return to “VLC for iOS, iPadOS and Apple TV”

Who is online

Users browsing this forum: No registered users and 19 guests