Since Apple supports only a few video and audio codecs, I was looking for a a/v framework for a new TVOS application. Videolan (creators behind the VLC player) providing a framework called TVVLCKit. I’m writing this article because I’ve spent a lot of time getting them working.

There are two ways to get the framework:

First is to easily download the nightly build:

Then drag and drop the framework to your project and add it to the Linked Frameworks and Libraries. In my test project this produced an error during the start of the application in the simulator. After reading the log files of the simulator I found out, that it’s missing an “Info.plist” file in the framework: Failed to load Info.plist from bundle at path

To solve this I copied the latest file from the git repository into the framework folder:

Second variant is to compile it yourself. You can follow the instructions of the wiki article from videolan.

For both variants you need to do the following steps, to use it in your swift project:

  1. Create a Bridging-Header file and add them in the Build Settings to the “Objective-C Bridging Header”
  2. Import TVVLCKit.h in the bridging header
    1. #import <TVVLCKit/TVVLCKit.h> when using the Framework
    2. #import “TVVLCKit/VLCMediaPlayer.h” when using the self compiled variant
  3. Add libc++.tbd and libiconv.tbd in the build phase “Linked Framework and Libraries”

Now you can use the player framework in your project by adding following sample code in the viewDidLoad():

let mediaPlayer = VLCMediaPlayer()
mediaPlayer.drawable = videoView // videoView is the UIView that should draw the window = VLCMedia(url: URL(string: "http://myURL")!)

When you now build the project, you might run into some compiler errors, e.g.:

Undefined symbols for architecture x86_64:
 "_AudioConverterReset", referenced from:
 _ffat_decode_flush in TVVLCKit(audiotoolboxdec.o)
 "_AudioConverterDispose", referenced from:
 _ffat_close_decoder in TVVLCKit(audiotoolboxdec.o)
 "_AudioConverterFillComplexBuffer", referenced from:
 _ffat_decode in TVVLCKit(audiotoolboxdec.o)

This means, that you need to add additional frameworks (in this case the audiotoolboxdec.o is missing). Find the matching framework (most a similar name) and add them to your project in the “Linked Framework and Libraries” section. Usually you need the following:

  • AVFoundation
  • AudioToolbox
  • CoreMedia
  • VideoToolbox