Search code examples
iosdropboxtvosavkit

AVKit unable to stream Dropbox Link Videos


I have been using AVKit to stream a video, below is the code I am using to stream videos in TVOS. But the problem is I am unable to do the same with the Dropbox Link? Is a Dropbox API integration required for this?

func _viewVideo(_ url: Foundation.URL)
{
    let url = Foundation.URL(string: "http://techslides.com/demos/sample-videos/small.mp4")

    let asset = AVURLAsset(url: url)

    let item = AVPlayerItem(asset: asset)

    let player = AVPlayer(playerItem: item)
    playerViewController?.player = player
    playerViewController?.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.size.width, height: self.view.bounds.size.height)
    playerViewController?.showsPlaybackControls = true

    self.view.addSubview((playerViewController?.view)!)
    player.play()
}

Solution

  • You can stream videos from Dropbox share links in Apple TV, however, you need to make a tiny change in the link.

    You need to force a file to download in your link, just change the end of the link from dl=0 to dl=1. In this way, Apple TV can stream videos from Dropbox share links.

    For reference: Force a file or folder to download, or to render on dropbox.com