Skip to content

Metadata change on radio stream and player state always buffering though playing

MobileVLCKit-3.0-pre-20161203-0659 Nightly

I am playing a shoutcast / icy cast radio but mediaMetaDataDidChange is only called a few times when the stream starts but not afterwards when title changes. Also even when I turn the network on my iPhone off, mediaPlayer.state is still buffering and mediaState.playing is always but but the time doesn't increase anymore.

Is there any to be immediately notified when VLC has no new data in the pipe / is unable to play currently in order to show correct icon (playing / paused) on the play button?

Thank you

func mediaPlayerStateChanged(aNotification: NSNotification!) {
    if mediaPlayer == nil {
        return
    }

    switch mediaPlayer.state {
    case .Buffering:
        print("buffering")
        break
    case .Playing:
        print("playing")
        break
    default: break
    }
    print(mediaPlayer.state.rawValue, mediaPlayer.playing, mediaPlayer.rate, mediaPlayer.time, mediaPlayer.media.state.rawValue, mediaPlayer.position)
    print(self.mediaPlayer.media.metaDictionary)
}

func mediaPlayerTitleChanged(aNotification: NSNotification!) {
    print("mediaPlayerTitleChanged")
    mediaPlayerStateChanged(aNotification)
}

func mediaMetaDataDidChange(aMedia: VLCMedia) {
    print("mediaMetaDataDidChange")
    print(mediaPlayer.media.metaDictionary)
}

func mediaDidFinishParsing(aMedia: VLCMedia) {
    print("mediaDidFinishParsing")
    print(mediaPlayer.media.metaDictionary)
}

func initVLC(media: VLCMedia) {
    if mediaPlayer == nil {
        mediaPlayer = VLCMediaPlayer()
        mediaPlayer.addObserver(self, forKeyPath: "time", options: .New, context: nil)
        mediaPlayer.addObserver(self, forKeyPath: "state", options: .New, context: nil)
        mediaPlayer.addObserver(self, forKeyPath: "playing", options: .New, context: nil)
        mediaPlayer.delegate = self
        NSTimer.schedule(repeatInterval: 5) { _ in
            self.mediaPlayerStateChanged(nil)
        }
    }
    mediaPlayer.stop()
    mediaPlayer.media = media
    mediaPlayer.media.delegate = self
}

override func observeValueForKeyPath(keyPath: String?, ofObject object: AnyObject?, change: [String : AnyObject]?, context: UnsafeMutablePointer<Void>) {
    print(keyPath)
    self.mediaPlayerStateChanged(nil)
}
Edited by Jean-Baptiste Kempf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information