13

I'm working on code that looks at the user's videos and passes them along to AVPlayer by way of an AVPlayerItem which takes a URL.

To get all the videos on an iOS device, you can do:

let videoNumber = MPMediaType.anyVideo.rawValue
let predicate = MPMediaPropertyPredicate.init(value: videoNumber, forProperty: MPMediaItemPropertyMediaType)
let query = MPMediaQuery.init()
query.addFilterPredicate(predicate)

if let items = query.items
{
    mediaCollection = MPMediaItemCollection(items: items)

    // -1 would indicate an error condition
    print("number of items in collection is \(mediaCollection?.count ?? -1)")
}

When you select the MPMediaItem you want to use from the items array, there should be an assetURL to go with it.

Trouble is, on my device, all of my assetURL properties are NULL. Coincidentally, while hasProtectedAsset for each of these items is false, isCloudItem for each of these items is true.

How can I come up with a valid assetURL that I can pass along to any media player? It feels somewhat bogus that developers can't get proper references & access to media in a user's iPod library.

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Have you found any solution for the above issue? – Abilash Balasubramanian Jun 29 '17 at 09:09
  • No, @AbilashBNair. Apple's DTS says it's a feature enhancement that I should request through https://bugreporter.apple.com ... In the meantime, you should up vote this question to increase its visibility and maybe attract a useful answer from somebody. – Michael Dautermann Jun 29 '17 at 12:44

0 Answers0