MPMediaPickerController with video media types not working
Asked Answered
G

2

5

I am trying to browse video stored in my iPod library using the new video media types. With any video type I get this error on the console:

Warning: Unsupported media types (1024), using MPMediaTypeAny.

After this error, the picker only shows audio types.

For reference, these are the new media types available in iOS5.0 (defined in MediaPlayer.framework/MediaItem.h):

// video (available in iOS 5.0)
MPMediaTypeMovie        = 1 << 8,
MPMediaTypeTVShow       = 1 << 9,
MPMediaTypeVideoPodcast = 1 << 10,
MPMediaTypeMusicVideo   = 1 << 11,
MPMediaTypeVideoITunesU = 1 << 12,
MPMediaTypeAnyVideo     = 0xff00,
Gilolo answered 27/2, 2012 at 23:53 Comment(0)
A
11

Can you query the Movie library in code successfully e.g.:

MPMediaPropertyPredicate *predicate = [MPMediaPropertyPredicate predicateWithValue:[NSNumber numberWithInteger:MPMediaTypeMovie] forProperty:MPMediaItemPropertyMediaType];

MPMediaQuery *query = [[MPMediaQuery alloc] init];
[query addFilterPredicate:predicate];

NSArray *items = [query items];

for (MPMediaItem* item in items)
{
    NSString* title = [item valueForProperty:MPMediaItemPropertyTitle];

    url = [item valueForProperty:MPMediaItemPropertyAssetURL];

}

You should see all movie titles. This is OK for me on IOS5 and iPad 2. I still have your problem though. A workaround is putting the above code results in its own modal view.

Americanize answered 29/3, 2012 at 14:54 Comment(2)
Fantastic! I'm assuming Apple will provide UI for this at some point. But this works.Gilolo
Hi, can you get your url actually? I can print out the title, but the url is null, I want to get the urls of the movies. Do you know if that is possible?Wilsey
E
2

SWIFT 3 form @John Goodstadt

import MediaPlayer

let predicate = MPMediaPropertyPredicate(value: MPMediaType.any.rawValue, forProperty: MPMediaItemPropertyMediaType)
    let query = MPMediaQuery()
    query.addFilterPredicate(predicate)
    let items = query.items
    for item in items! {
        DLog("title: \(item.title); url: \(item.assetURL)")
    }

then you can change type as you need.

Erikaerikson answered 8/2, 2017 at 2:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.