2012-06-28 3 views
0

백그라운드에서 재생할 수있는 오디오 전용 플레이어가 내 앱에 있습니다. 처음에는 잘 작동하는 MPMoviePlayerController를 사용했지만 문제는 앞뒤 검색 (또는 슬라이더 사용)을 지원하지 않는다는 것입니다.오디오 전용 iOS가있는 HLS

녹음 중 일부는 1 시간이며, 누군가가 녹음 중에 중단되어 다시 원래 장소로 돌아가고 싶다면 처음부터 다시 시작해야합니다. AVAudioCoder를 사용하여 솔루션으로 보였으므로 코드가 변경되어 장치에없는 URL에서는 작동하지 않습니다.

나는 HTTP 라이브 스트리밍을 사용하고 .m3u8 파일이 있습니다. 슬라이더를 사용하여 재생 위치를 변경할 수있는 인터넷 소스의 .m3u8 및 .mp3 파일을 사용하는 솔루션을 쉽게 구현할 수 있습니까? (백그라운드에서 재생이 필요로하고, 내가 MPMoviePlayerController의 인터페이스를 사용할 수 없습니다)

업데이트 : MPMoviePlayerController를 사용하여 뒤로,하지만 몇 가지 이상한 행동. .m3u8 재생 목록을 재생하고 새 위치를 설정하면 currentPlaybackTime을 쿼리 할 때 지정된 값이 올바른 값으로 설정되지만 사운드는 중단되지 않은 것처럼 계속 재생됩니다.

플레이어를 일시 중지 할 때 플레이어가 일시 중지하고 계속 재생되는 시간을 설정하지만 적어도 'currentPlaybackTime'은 올바른 현재 위치를 제공합니다.

id appDelegate = (iDomsAppDelegate *) [[UIApplication sharedApplication] delegate]; double length = [[appDelegate audioPlayer] duration]; if (길이> 0) { float sliderValue = [_ 슬 라이더 값]; double time = sliderValue/100 * length;

ID AppDelegate에 = (iDomsAppDelegate *) [UIApplication sharedApplication] 대리자] : 상기와 같이

NSTimeInterval playBackTime = time; 

NSLog(@"Requested time: %f vs current time %f", playBackTime, [[appDelegate audioPlayer] currentPlaybackTime]); 
//[[appDelegate audioPlayer] pause]; 
[[appDelegate audioPlayer] setCurrentPlaybackTime:playBackTime]; 
//[[appDelegate audioPlayer] setInitialPlaybackTime:playBackTime]; 
//[[appDelegate audioPlayer] play]; 
NSLog(@"Requested time: %f vs current time %f (2)", playBackTime, [[appDelegate audioPlayer] currentPlaybackTime]); 

}

각을 제 I은 라벨을 업데이트하고이 날의 동작을 준다

double time = [[appDelegate audioPlayer] currentPlaybackTime]; double length = [[appDelegate audioPlayer] duration]; NSLog (@ "상태 : % i, 시간 : % f", [[appDelegate audioPlayer] playbackState], [[appDelegate audioPlayer] currentPlaybackTime]); if (길이> 0) { double pos = 시간/길이 * 100; [_slider setValue : (float) pos]; [_slider setEnabled : true]; ;

NSInteger seconds = (int) length % 60; 
NSInteger minutes = ((int) length/60) % 60; 

double playableDuration = [[appDelegate audioPlayer] playableDuration]; 
if(playableDuration > 0 && playableDuration < length){ 
    int downloaded = (int)((float)((float)playableDuration/(float)length) * 100); 
    [_unknownLength setText:[NSString stringWithFormat:@"Total duration: %02i:%02i (%02i%% downloaded)", minutes, seconds, downloaded]]; 
} else { 
    [_unknownLength setText:[NSString stringWithFormat:@"Total duration: %02i:%02i", minutes, seconds]];  
} 

한다} else { [FALSE는 _slider는 setEnabled] [_unknownLength setText : [NSString stringWithFormat : @ "총 지속 시간을 알 수 없음]]];
}

NSInteger 초 = (int) 시간 % 60; NSInteger 분 = ((int) 시간/60) % 60; [_ 위치 setText : [NSString stringWithFormat : @ "% 02i : % 02i", 분, 초]];

+0

왜 MPMoviePlayerController가 HTTP 스트리밍과 관련하여 검색을 지원하지 않는다고 생각하십니까? – Till

+0

좋은 질문입니다. 재생 헤드를 위치로 이동하는 것은 개인적인 방법이라고 생각했지만 MPMediaPlayback 프로토콜의 사양을 다시 읽으면 다른 것을 제안하는 것 같습니다. 왜 그것이 작동하지 않았는지 잘 모르겠지만, 다시 한번 살펴 보겠습니다. –

+0

안심하십시오, 그것은 매력처럼 작동합니다. : D – Till

답변

0

FFMPEG 전용 오디오 용 세분화가 올바르게 작동하지 않았지만 이제는 GIT Repo 헤드에서 고정됩니다. MPMoviePlayer 컨트롤러를 사용하면 완벽하게 작동하므로 세그먼트 크기 단위로 빠르게 찾을 수 있습니다.

관련 문제