Camille R
Camille R

Reputation: 1433

WatchOS - presentMediaPlayerControllerWithURL not playing video

I'm trying to achieve a small app where you download an MP4 video in background on the watch, and play once downloaded.

Using WKInterfaceMovie.setVideoURL works well with an https link, but I want to customize the loading UI.

After downloading the video file, I move it to a shared group :

originalURL : Optional("/private/var/mobile/Containers/Data/PluginKitPlugin/FD57E33D-4657-497B-9823-A53D289CDF0B/Library/Caches/com.apple.nsurlsessiond/Downloads/com.test.TestWatchVideo.watchkitapp.watchkitextension/CFNetworkDownload_jKLIrU.tmp")

destinationURL : Optional("/private/var/mobile/Containers/Shared/AppGroup/018DA2BA-EB53-45DA-B3EA-792D4879E601/Library/Caches/SampleVideo_360x240_1mb.mp4")

I'm using removeItemAtURL ( if old file exist ) then copyItemAtURL to move the original file.

=> BUT when trying presentMediaPlayerControllerWithURL , it dismisses before playing video and says :

Error: Error Domain=com.apple.watchkit.errors Code=4 "The operation could not be completed" UserInfo={NSLocalizedFailureReason=An unknown error occurred (1), NSUnderlyingError=0x16d71f20 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}, NSLocalizedDescription=The operation could not be completed}

I've read quite a few threads on StackOverflow and Forums, and none have helped me.

Thanks !

Upvotes: 1

Views: 284

Answers (2)

keyser_soze1123
keyser_soze1123

Reputation: 1

switch on the App Groups of WatchKit App ...

Upvotes: 0

Camille R
Camille R

Reputation: 1433

OK, this was an issue of App Group Capabilities of the WatchKit App; The Application had the good right, the WatchKit App Extension was OK too, but WatchKit App didn't => Operation not permitted only when trying to play video.

This was working on the simulator, no matter you configuration.

Upvotes: 1

Related Questions