現在、iOSのTableViewCell内で動画を再生する再生プログラムを作っています。現在は、tableView:cellForRowAtIndexPath: 内で動画のviewのaddsubViewをしているため、次のTableViewCellが表示されたとたんに再生が始まる仕組みなっています。
これを例えば、「画面半分以上の大きさで表示されているTableViewCell内の動画を再生する」の処理を行いたいとする場合、tableView:cellForRowAtIndexPath:以外の独自のメソッド内で動画再生を書く必要があると思っています。
"セルが画面半分以上の場合"に~のような処理を行うというメソッドはどう書けばいいかを考えています。
アドバイスいただけると嬉しいです。
※ちなみにセルの高さは500です。
lang
1- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 2 3 NSURL *url = [NSURL URLWithString:@"https://www.youtube.com/watch?v=nKIu9yen5nc"]; 4 moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url]; 5 moviePlayer.controlStyle = MPMovieControlStyleNone; 6 moviePlayer.scalingMode = MPMovieScalingModeAspectFit; 7 moviePlayer.useApplicationAudioSession = YES; 8 CGRect frame = _cell.movieView.frame; 9 [moviePlayer.view setFrame:frame]; 10 [cell.movieView addSubview: moviePlayer.view]; 11 [cell.movieView bringSubviewToFront:moviePlayer.view]; 12 13 [[NSNotificationCenter defaultCenter] addObserver:self 14 selector:@selector(moviePlayBackDidFinish:) 15 name:MPMoviePlayerPlaybackDidFinishNotification 16 object:moviePlayer]; 17 //[NSThread sleepForTimeInterval:1.0f]; 18 [moviePlayer setShouldAutoplay:YES]; 19 [moviePlayer prepareToPlay]; 20 [moviePlayer play]; 21} 22- (void) moviePlayBackDidFinish:(NSNotification*)notification { 23 [moviePlayer play]; 24}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。