macOS: [VLCKit-4.0-current] 'mediaPlayerTimeChanged' problem with VLCMediaListPlayer
Environment:
- VLCKit 4.0-latest (rev: 4.0.0-dev-20569-g269bb8df41)
- macOS 13.0
- XCode 14.0.1
- Swift 5.7
Code:
import Cocoa
import VLCKit
class ViewController: NSViewController, VLCMediaPlayerDelegate, VLCMediaListPlayerDelegate {
let mediaURL = VLCMedia(url: URL(string: "https://streams.videolan.org/streams/mp4/Mr_MrsSmith-h264_aac.mp4")!)
let videoView = VLCVideoView(frame: NSRect(x: 5, y: 5, width: 500, height: 400))
var mediaPlayer = VLCMediaPlayer()
let vlcMediaList = VLCMediaList()
var mediaListPlayer: VLCMediaListPlayer?
override func viewDidLoad() {
super.viewDidLoad()
// custom code
vlcMediaList.add(mediaURL)
self.view.addSubview(videoView)
let mlp = VLCMediaListPlayer(drawable: videoView)
mlp.repeatMode = .repeatCurrentItem
mlp.mediaList = self.vlcMediaList
self.mediaListPlayer = mlp
self.mediaPlayer = mlp.mediaPlayer
mediaPlayer.delegate = self
mlp.playItem(at: 0)
//mediaPlayer.media = mediaURL // it works
//mediaPlayer.play()
}
func mediaPlayerStateChanged(_ aNotification: Notification) {
if mediaPlayer.state == .opening { print("OPENING") }
if mediaPlayer.state == .stopped { print("STOPPED") }
}
func mediaPlayerTimeChanged(_ aNotification: Notification) {
print("currtime: \(String(describing: mediaPlayer.time)) position: \(String(describing: mediaPlayer.position))")
}
}
Issue:
'mediaPlayerTimeChanged' called only once (at media stop)
OPENING
currtime: 01:18 position: 1.0
STOPPED
OPENING
currtime: 01:18 position: 1.0
STOPPED
OPENING
currtime: 01:18 position: 1.0
...
with VLCMediaPlayer() it works
mediaPlayer.media = mediaURL
mediaPlayer.play()
OPENING
currtime: 00:00 position: 0.0032901292448048658
currtime: 00:01 position: 0.016107539280283835
currtime: 00:02 position: 0.028481690319310693
currtime: 00:03 position: 0.041153940699442476
currtime: 00:04 position: 0.053826026355803344
currtime: 00:05 position: 0.066486467308667
currtime: 00:06 position: 0.07915885707045109
currtime: 00:07 position: 0.09154793461733401
...