itunes库在ipad中实现

时间:2011-10-07 09:32:19

标签: iphone objective-c ios ipad itunes

我正在开发一个我无法在我的app中访问iPod视频的应用程序。所以我正在考虑集成iTunes.so我可以从iTunes商店和商店下载视频它到本地目录,从该目录我可以播放视频。

我可以在popOverController中播放照片库中的视频,但无法在

中播放
-(IBAction)SelectVideo:(id)sender
   {

       UIImagePickerController *ImageVideoPicker = [[UIImagePickerController alloc] init];
       ImageVideoPicker.sourceType =  UIImagePickerControllerSourceTypePhotoLibrary;
       ImageVideoPicker.delegate = self;
           [ImageVideoPicker setMediaTypes:[NSArray arrayWithObjects:(NSString *)kUTTypeMovie, nil]];

  /////////videoLibrary is PopOver to show Videos Of photo gallery////////  
            VideoLibrary= [[UIPopoverController alloc]
               initWithContentViewController:ImageVideoPicker];
          [VideoLibrary presentPopoverFromRect:addVideo.frame inView:self.videoView   permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}

//////////////////////////////////////////功能确实选择了视频//////////////////

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
 {

        NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
        if ([mediaType isEqualToString:@"public.movie"]){

    NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];
    UIAlertView *alurl=[[UIAlertView alloc]initWithTitle:@"message"    message:videoURL delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
            [alurl show];
            [alurl release];
  //////////////this url is used to play video in
 app.VideoUrl=videoURL;          
     NSLog(@"%@",app.VideoUrl);

}
[picker dismissModalViewControllerAnimated:YES];
 }

我无法玩这个app.videoUrl.So如果有人做过Itunes Store集成,请指出我正确的方向。 谢谢

1 个答案:

答案 0 :(得分:0)

您实际上希望MPMediaPickerController的mediaTypes属性设置为适当的按位掩码:

// video media types
MPMediaTypeMovie        = 1 << 8,
MPMediaTypeTVShow       = 1 << 9,
MPMediaTypeVideoPodcast = 1 << 10,
MPMediaTypeMusicVideo   = 1 << 11,
MPMediaTypeVideoITunesU = 1 << 12,
MPMediaTypeAnyVideo     = 0xff00,

// generic media type
MPMediaTypeAny          = ~0