I\'ve read some posts, but I don\'t find the answer I need: is it possible to play a video file or a video from a URL in a WatchKit app?
I am sharing objective-c and swift code block. But previoues comment explained. Videos play only local.
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
Swift
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()
}
}