rick
rick

Reputation: 1057

Get Video Data in Videos Application

I want my player to play videos that are in Video app.

I access Media Library, and want to get list of videos, and when user selected a video, my player get the video data and play it on my own player.

How can I get the video data?

Notice that I want to play videos, not songs.

This is my code to get videos:

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

It takes videos as MPMediaItem.

Does it takes videos correctly? If yes, I want to get a video data after user selected one.

Upvotes: 3

Views: 402

Answers (2)

A.bee
A.bee

Reputation: 522

I think @Scriptable is right. But notice that downloaded videos will not be accessible through Videos (renamed to TV) application! TV shows iTunes purchased movies.

You can access downloaded videos through Photos (Gallery). If you mean downloaded videos from the web or other apps.

Upvotes: 2

Scriptable
Scriptable

Reputation: 19758

I don't think it is possible, at least by using MediaPlayer.

You can only access videos stored in the Photos app/library.

Use the Media Player framework—which is part of MusicKit—to control playback of the user's media from your app. If your app incorporates music, you can use this framework to search for audio content (songs, podcasts, books, and so on) in the user's library. You can then play that content directly or ask the system Music app to play it. For example, a game might give users the option to play their own music while completing a particular game level. (Emphasis mine)

Upvotes: 1

Related Questions