Emil Atanasov blog

How to write a good video player on tvOS

I’ve been developing different projects with Swift. Mostly phone apps (iOS apps), apps for iPad (iPadOS), native apps for macOS. So far, I’ve never tried to write anything from scratch for tvOS. This is my first try. I’m planning to develop a generic video player. Later will decide how to build on top of it.

I want to use the new technology SwiftUI. Also I should use the good bits (aka native controls) in tvOS. This will make the app look slick.

Before diving into the code, I should read couple of articles related to tvOS to get better understanding what tvOS gives me. In the long run this will save me time.

I’ve found the following repo and I started reading step by step.

Should I use TVML (and JS) or I should stick to my initial idea of pure native app?

I’ve started looking for answers and there was pretty good discussion on StackOverFlow

Also, it turned out that both UIKit(SwiftUI) and TVML can be mixed drectly - SOF.

In my case, I want to have a codebase that could be ported to iPadOS, macOS and iOS without problem. But I won’t need everything to be the same. I can use the TVML to bootstrap my video player. Then I can see, how to rewrite it using SwiftUI, which can be shared across different devices.

Here is a list of some opensource projects that I want to check, before taking my final decision:

https://github.com/insidegui/WWDC-tvOS

https://developer.apple.com/library/archive/samplecode/TVMLCatalog/Introduction/Intro.html

I plan to support videos that are shared from local device. For example a windows server. This means that the app should support SMB sharing (aka Windows Sharing Protocol) then I would need a native library that implements it. Here is a link to one repo, that can be used.

https://github.com/naxos/SMBClient

In this post, I’ve tried to get you familiar with the technologies available on tvOS. I’ll keep bloging how it goes and which technology is better. I’m pretty sure that the answer is - It depends.