2014-03-03 315 views
1

我試圖從YouTube和Vimeo嵌入視頻,在現階段,我做到以下幾點:嵌入YouTube和Vimeo視頻

if([item.source isEqual: @"youtube"]) 
    { 
     UIView *videoContainerView = [[UIView alloc]initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 320.0f)]; 


     XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:item.videoId]; 
     [videoPlayerViewController presentInView:videoContainerView]; 
     [videoPlayerViewController.moviePlayer play]; 
     videoPlayerViewController.moviePlayer.shouldAutoplay = NO; 

     [self addSubview:videoContainerView]; 

    } else if ([item.source isEqual:@"vimeo"]) { 

      [YTVimeoExtractor fetchVideoURLFromURL:item.url quality:YTVimeoVideoQualityMedium completionHandler:^(NSURL *videoURL, NSError *error, YTVimeoVideoQuality quality) { 
      if (error) { 
       NSLog(@"Error : %@", [error localizedDescription]); 
      } else if (videoURL) { 
       NSLog(@"Extracted url : %@", [videoURL absoluteString]); 

       self.playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL]; 
       [self.playerView.view setFrame:CGRectMake(0, 0, 320, 320)]; 
       self.playerView.view.backgroundColor = [UIColor grayColor]; 

       [self addSubview:self.playerView.view]; 
      } 
     }]; 

    } 

YouTube視頻即時通訊使用XCDYouTubeVideoPlayerViewController,以及Vimeo的i'm使用YTVimeoExtractor。現在,我有兩個問題

第一個問題:

YouTube的部分作品般的魅力,但Vimeo的部分doesn't工作。從我的網絡服務器,我得到以下網址:

http://vimeo.com/85004906 

和URL得到由YTVimeoExtractor提取後,我有下面的代碼片段:

http://pdl.vimeocdn.com/85824/823/226049076.mp4?token2=1393842513_dd8e4d573f67656c80b91b3130d42824&aksessionid=ac7102b713f0b2c0 

這是這是我設置成MPMoviePlayerViewController的videoUrl。但我只得到一些灰色背景幀中的任何視頻都

第二問題所示:

蘋果醫生說:如果您的應用程序提供了在蜂窩網絡上的視頻,而視頻超過10分鐘時長任或5分鐘內的5 MB數據,則需要使用HTTP Live Streaming。

所以,如果我不使用這個,我的應用程序將被拒絕?如果我不得不使用http流媒體,我必須爲高清視頻做額外的部分?

謝謝!

+0

請解釋越多,你的「不工作Vimeo的一部分」的意思,在這裏失敗?你沒有得到答覆,或者你得到一個錯誤的網址或你得到一個空的URL? – MuhammadBassio

+0

我要編輯我的文章,我希望現在好轉:) – Davis

回答

1

我檢查了YTVimeoExtractor &它使用正確的技術來提取vimeo視頻,並且上面的URL看起來正確。

我不知道爲什麼MPMoviePlayerViewController沒有播放視頻,但我建議您嘗試使用AVPlayer發揮它(而不是像MPMoviePlayerViewController簡單但功能更強大)&檢查,如果你得到了相同的結果。

關於5MB的限制,您不必擔心,您的應用將獲得批准:)