Reputation: 45
I'm creating a video streaming player, using mobileVLCkit. and want to know if the video data of requested URL is being sent. What code should I write?
I'm using Xcode 10, swift 4, mobileVLCkit for VLCMediaPlayer.
///// below is my code
myPlayer = VLCMediaPlayer.shared
myPlayer.media = VLCMedia(url : URL(string : myURL)!)
myPlayer.drawable = self.myPlayer_view
myPlayer.play()
///// below is what i tried
myPlayer.media.isplaying() // not worked
func mediaPlayerStateChanged(_ aNotification: Notification!) {} // not worked
When I tried myPlayer.media.isplaying(), I expected I could check there is data. But It is simply player is playing or not. So If there is video data but it is stopped, The result is myPlayer.media.isplaying() = false
Upvotes: 0
Views: 1525
Reputation: 353
You can check the state with VLCMediaPlayerDelegate
.
Don't forget to set your player as the delegate for example:
myPlayer.delegate = self
Then listen for the changes like so:
extension PlaybackViewController: VLCMediaPlayerDelegate {
func mediaPlayerStateChanged(_ aNotification: Notification!) {
if mediaPlayer.state == .playing {
// Currently playing...
}
// Handle other states...
}
}
Upvotes: 2