Play Video From URL in WatchOS 2

2019-04-13 05:23发布

问题:

So recently Apple® released the second operating system for their Apple Watch®. With this update, Apple Watch® can now have HTTP requests and internet connection by itself. They added the

 WKInterfaceMovie

Which loads a video from a url with the method

" - setMovieURL: Declaration (New in watchOS 2.0)

SWIFT

  func setMovieURL(_ URL: NSURL)

OBJECTIVE-C

- (void)setMovieURL:(NSURL * _Nonnull)URL

"

If I input a URL with any .mov video online. The WKInterfaceMovie closes automatically. Sometimes the "Downloading" circle comes and begins to load up but I haven't been able to show up the remote video (Not stored in the Apple Watch®)

I would be amazed if someone can help me.

Thanks

回答1:

It only works with https URLs, regardless of the App Transport Security (ATS) settings.

Source WatchKit Framework Reference:

If you specify a URL for a file on a remote server, this method downloads the file first and displays a progress indicator showing the progress of the operation. Because WatchKit uses App Transport Security (ATS) when downloading files from a web server, the file must be on a secure server, and the URL must use the https scheme. If your server does not support ATS–level security, download the file yourself before playing it.