在WatchKit应用程序中播放video

我已经阅读了一些文章,但我没有find我需要的答案:是否可以在WatchKit应用程序中播放video文件或URL中的video?

当前版本的WatchKit(8.2)不支持video。 有可能创build一个animation系列的图像,并在手表上播放它们,但存储和传输成本可能意味着这个“video”将会很短而且帧率很低。 据推测,这是他们在其中一个主题演示中用来显示车库门video的技术。

当前版本的WatchOS 2.0允许播放video,但只能播放本地video。 请参阅WKInterfaceMovie类的参考: https : //developer.apple.com/library/prerelease/watchos/documentation/WatchKit/Reference/WKInterfaceMovie_class/index.html#//apple_ref/occ/cl/WKInterfaceMovie

我正在分享objective-c和swift代码块。 但是,前面的评论解释。 video只播放本地。

Objective-C的

 #import "InterfaceController.h" @interface InterfaceController() @end @implementation InterfaceController - (void)awakeWithContext:(id)context { [super awakeWithContext:context]; // Configure interface objects here. } - (void)willActivate { // This method is called when watch view controller is about to be visible to user [super willActivate]; NSURL* url = [[NSBundle mainBundle] URLForResource:@"test" withExtension:@"mov"]; [self.myMoviePlayer setMovieURL:url]; } - (void)didDeactivate { // This method is called when watch view controller is no longer visible [super didDeactivate]; } @end 

迅速

 import WatchKit import Foundation class InterfaceController: WKInterfaceController { @IBOutlet var myMoviePlayer: WKInterfaceMovie! override func awakeWithContext(context: AnyObject?) { super.awakeWithContext(context) // Configure interface objects here. } override func willActivate() { // This method is called when watch view controller is about to be visible to user super.willActivate() let url = NSBundle.mainBundle().URLForResource("test", withExtension: "mov") self.myMoviePlayer.setMovieURL(url!) } override func didDeactivate() { // This method is called when watch view controller is no longer visible super.didDeactivate() } }