* 우리가 비디오를 볼 수있는 iPhone 응용 프로그램을 만들고 있습니다 ... 다음, 뒤로 버튼을 구현하고 싶으므로 내 자신의 컨트롤을 만들었으므로 UI에 대한 테마를 모두 표시 할 수 있습니다. 문제는 다른 내용으로 MoviePlayer를 다시 시작하는 것입니다 ... 어떤 아이디어 ??? 재생이 마무리했을 때동일한 MPMoviePlayerController에서 다른 비디오를 재생하는 방법은 무엇입니까?
나는 동일한 구성을 사용할 수 있습니다, 나는 비디오가 다른 재생을 시작 재생 종료되면 ... 내가 contentUrl를 설정하려고했지만 예외를 trows ... 의미 :
2012-04-17 11:37:41.198 NexTest2[8218:11f03] *** Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 11.5]'
viewController.m
내가 컨트롤과 같은 두 가지 뷰 사용하고 원인 다음- (void)viewDidLoad{
[super viewDidLoad];
fileURL = [NSURL URLWithString:urlString];
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
moviePlayerController.controlStyle = MPMovieControlStyleNone;
[moviePlayerController setShouldAutoplay:YES];
[self addObservers];
/* Inset the movie frame in the parent view frame. */
CGRect viewInsetRect = CGRectInset ([self.view bounds],0.0, 0.0);
[[moviePlayerController view] setFrame: viewInsetRect ];
[self.view addSubview:moviePlayerController.view];
[self resizeControlViews];
}
resizeControlViews에 나는이 있습니다
을여기 모두가 정상적으로 작동합니다.이보기 중 하나에서 탐색을 제어하는 슬라이더가 있으며, 다른 하나는 재생, 다음 및 뒤로 버튼입니다. 플레이어가 나는를 사용하여 재생 될 때
//Add the observers to the player
-(void)addObservers{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackStarted:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setDurationLabel:) name:MPMovieDurationAvailableNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyWindowChanged:) name:UIWindowDidBecomeKeyNotification object:nil];
}
그렇게 처리 할 수있는 : 나는
나는 재생을 제어하기 위해 이러한 관측을 추가했습니다 ... 문제는이 뷰의 UI 구성 요소를 부엉 어쩌면 생각 이 셀렉터와 MPMoviePlayerPlaybackStateDidChangeNotification :
-(void)timerRunning{
self.currentTime.text = [self floatToStringTime:(moviePlayerController.currentPlaybackTime)];
self.timeBar.value = moviePlayerController.currentPlaybackTime/moviePlayerController.duration;
if (moviePlayerController.playbackState == MPMoviePlaybackStatePlaying) {
[self performSelector:@selector(timerRunning) withObject:nil afterDelay:0.5];
}
}
01 :
//called when the playback state changes of state
- (void)playbackStarted:(NSNotification*)notification {
MPMoviePlayerController *player = notification.object;
if (player.playbackState == MPMoviePlaybackStatePlaying) {
[self timerRunning];
}
}
플레이어가 난이 방법으로 그것을 모니터링 "재생"경우
내가 설정하는 줄을 모니터링하고 있습니다 동안 ...입니다 23,516,그래서 아마 여기가 문제입니다 ...하지만
가 완벽하게 작동 하나의 비디오 ...와 나는 실수가 사를했습니다 값을 슬라이더에 넣을 수는 있지만 실제로 이유를 모르겠다. 다른 비디오 나 비디오를 멈추는 것이 여전히 실행되어서 플레이어가이 예외를 던지는 기간이나 현재 재생을하지 못했을 때라고 생각한다. 어떻게 해결할 수 있을까? 이 코드는 실수입니다.이 코드를 다른 부분으로 옮길 수도 있습니다 ...
self.timeBar.value = moviePlayerController.currentPlaybackTime/moviePlayerController.duration;
주셔서 감사합니다. 일반적으로 영화 플레이어를 다시 사용하려면 해당 플레이어를 릴리스 한 다음 새 콘텐츠를 추가해야합니다. – DivineDesert
@DimplePanchal 재사용을 위해 플레이어를 릴리스해야하는 것은 올바르지 않습니다. contentUrl을 설정하기 만하면됩니다. – Till
@ Till Ya, 나는 또한 그 것을 발견했다. 그러나 movieplayer에 대한 contentUrl 만 설정하면 일반적으로 iphone sdk에서 uncatchable 충돌이 발생한다. 나는 그 이유를 모른다.하지만 이것은 내가 관찰 한 것이다. – DivineDesert