VLCKit not playing local files.
Posted: 23 Jun 2019 16:04
I have been experimenting with the VLCKit library for macOS. I was able to display the video in a simple Cocoa app using the following code.
As you can see it is as simple as it can get. It displays a video from a web URL.
The problem occurs now if I try to display a local file. I tried creating a local url using:
and passing the local absolute path. That didn't work.
I then tried passing the absolute path string directly to the VLCMedia constructor with the path argument.
Which also didn't work.
By "didn't work" I mean that the view was just transparent nothing happened, no log in the console, it seemed like the setupPlayer never got executed, which it however did.
I am asking hence why I am not able to play local files
Code: Select all
import Cocoa
class ViewController: NSViewController {
var player: VLCMediaPlayer = {
return VLCMediaPlayer()
}()
@IBOutlet weak var playerView: NSView!
override func viewDidLoad() {
super.viewDidLoad()
setupPlayer()
}
private func setupPlayer() {
let url = URL(string: "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4")!
let media = VLCMedia(url: url)
player.media = media
player.drawable = playerView
player.play()
}
}
The problem occurs now if I try to display a local file. I tried creating a local url using:
Code: Select all
fileURL(withPath:)
I then tried passing the absolute path string directly to the VLCMedia constructor with the path argument.
Code: Select all
VLCMedia(path <absolute path>)
By "didn't work" I mean that the view was just transparent nothing happened, no log in the console, it seemed like the setupPlayer never got executed, which it however did.
I am asking hence why I am not able to play local files