English 中文(简体)
一本名为“基准”的电影
原标题:Play movies from an album in "Photos"

我如何从一个名为“地图集”的电影中拍摄一部电影? 我不想利用UIImagePickerController来浏览电影,但我希望能够具体说明电影的名称(或某种影子),就像在以下法典中那样。 以下法典在当地播放录像。 我如何改变在照片上储存的名为“Video”的小册子上播放录像的道路? 非常感谢你的帮助。

NSString *url = [[NSBundle mainBundle]

                     pathForResource:@"Movie1"

                     ofType:@"MOV"];

MPMoviePlayerViewController *playerViewController =

    [[MPMoviePlayerViewController alloc]

     initWithContentURL:[NSURL fileURLWithPath:url]];

[[NSNotificationCenter defaultCenter]

     addObserver:self

     selector:@selector(movieFinishedCallback:)

     name:MPMoviePlayerPlaybackDidFinishNotification

     object:[playerViewController moviePlayer]];

[playerViewController.view setFrame: self.view.bounds];
[self.view addSubview:playerViewController.view];

MPMoviePlayerController *player = [playerViewController moviePlayer];

[player play];

[playerViewController release];
最佳回答

我最后使用了ALAssetsLibrary,并制作了一系列的陶器,储存了照片集的录像片。 在这里,如果该法典对某人有用的话。

NSMutableArray *assets =[[NSMutableArray alloc]init];
NSMutableArray *assetURLs = [[NSMutableArray alloc] init];
NSMutableArray *assetGroups = [[NSMutableArray alloc] init];

ALAssetsLibrary *library = [[ALAssetsLibrary alloc]init];
void (^assetEnumerator)( ALAsset *, NSUInteger , BOOL *) = ^(ALAsset *result, NSUInteger index, BOOL *stop)
{
    if(result != NULL)
    {
        NSLog(@"Asset: %@", result);
        //[assets addObject:result];
        if(![assetURLs containsObject:[result valueForProperty:ALAssetPropertyURLs]]) {
            if([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
                [assetURLs addObject:[result valueForProperty:ALAssetPropertyURLs]];
                [assets addObject:result];
            }
        }

    }
};    
void (^assetGroupEnumerator)( ALAssetsGroup *, BOOL *) =  ^(ALAssetsGroup *group, BOOL *stop)
{
    if(group != nil)
    {
        [assetGroups addObject:group];
        NSLog(@"GROUP: %@", group);
        [group enumerateAssetsUsingBlock:assetEnumerator];
    }      
};    
void(^ErrorBlock)(NSError*)=^(NSError *error)
{
    NSLog(@"Failure");
};    


[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
                       usingBlock:assetGroupEnumerator
                     failureBlock: ErrorBlock
 ];  

Then, initialize the MPMoviePlayerViewController object as follows:

MPMoviePlayerViewController *playerViewController =[[MPMoviePlayerViewController alloc] initWithContentURL:[[[assets objectAtIndex:counter defaultRepresentation] url]]; // counter is incremented to play all videos or set whatever way to play what you want.
问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签