Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play Vimeo content on tvOS

Tags:

vimeo

tvos

Similar to this question asking about how to play YouTube videos on tvOS, I'd like to play Vimeo videos in the app I'm building. However, as explained here, regular web views (which is how I do things in iOS) are out.

How would I go about playing a Vimeo video on tvOS assuming I knew the URL to the video page but not the URL to the raw .mp4 file?

like image 697
Nick Avatar asked Sep 16 '15 04:09

Nick


People also ask

How do I Play Vimeo videos on my TV?

To play Vimeo videos on your TV, we recommend using one of the platforms listed above. Vimeo apps on these platforms are no longer supported: Some smart TV platforms provide web browsers that can access standard websites. The Vimeo website and video player are not tested in TV web browser environments and are not supported.

Can I watch Vimeo videos on devices other than my computer?

There are lots of ways to watch Vimeo videos on devices other than your computer — to start, native Vimeo apps are available for these popular app platforms and devices: Search for “Vimeo” in the Roku channel store or visit the app listing here.

How do I watch Vimeo on Amazon Fire TV?

Search for “Vimeo” on the Amazon Fire TV device, or visit the app listing here. Cast from the Vimeo Android or iOS mobile apps, learn more here. Note: for more information on using showcases for custom channels on Roku and Amazon Fire, visit this page.

What is Vimeo and how does it work?

Simply put, Vimeo takes care of all the technology needs and customer service, giving creators more time to focus on content creation, growing their brand, and connecting with their audience. I landed on Vimeo as an OTT service because you really felt like you were talking to people, not automated emails.


2 Answers

Well, apparently, there is no way to play a Vimeo video in a WebView, because tvOS SDK doesn't have a WebView. The only option we have is AVPlayer, but it requires a direct URL to a video, and Vimeo won't give us direct video URLs for free. Right now, the only possible way is to purchase Vimeo's PRO membership ($199 per year at the moment) and retrieve direct video URLs via Vimeo's API.

EDIT: as nickv2002 noted, this approach will give you direct URLs only to YOUR OWN videos. Thi means, that even with Vimeo PRO you can't just take any video on Vimeo and get a direct URL for it.

like image 91
xinatanil Avatar answered Oct 16 '22 10:10

xinatanil


Using this pod, tvOS can play vimeo contents, Install

pod 'YTVimeoExtractor'

and

 import YTVimeoExtractor

And use this function to play the video

func playVimeoVideo(videoId: String)
{
    YTVimeoExtractor.shared().fetchVideo(withVimeoURL: "https://vimeo.com/video/\(videoId)", withReferer: nil) { (video:YTVimeoVideo?, error:Error?) in

        if let streamUrls = video?.streamURLs
        {
            var streamURL: String?
            var streams : [String:String] = [:]
            for (key,value) in streamUrls {

                streams["\(key)"] = "\(value)"
                print("\(key) || \(value)")
            }

            if let large = streams["720"]
            {
                streamURL = large
            }
            else if let high = streams["480"]
            {
                streamURL = high
            }
            else if let medium = streams["360"]
            {
                streamURL = medium
            }
            else if let low = streams["270"]
            {
                streamURL = low
            }

            if let url = streamURL
            {
                let videoURL = NSURL(string: url)
                let player = AVPlayer(url: videoURL! as URL)
                let playerViewController = AVPlayerViewController()
                playerViewController.player = player
                self.present(playerViewController, animated: true) {
                    playerViewController.player!.play()
                }
            }
        }
    }
}
like image 20
anas.p Avatar answered Oct 16 '22 09:10

anas.p