WKInterfaceMovie is a new UI components in WatchKit to play video and audio.

Let’s get started to build a app to play local video.

As usual, create iOS app project with a single view for simplicity and add new target for watchOS application.

First, drag the WKInterfaceMovie in Object Library to the main Interface in storyboard and connect it to the IBOutlet in your code.

image

Now, we need to feed the component with movie by setMovieURL:. Please note WKInterfaceMovie only support local file url which means the media file is in your Apple Watch. In project, place it in Extension for watch app.

Then we can customize the movie with video gravity, poster image and loops.

The video gravity means resizing options including WKVideoGravityResizeAspect, WKVideoGravityResizeAspectFill, WKVideoGravityResize. We can find detailed explanation from WKVideoGravity.

The poster image is shown to tell the user content hint about the video. Set the loops YES or NO to tell if you want to play the video again and again. We can set these values in Attributes Inspector or programmatically.

Build, run and pray!

{<1>}gif