2014-04-28 3 views
0

기본 오디오 AVPlayer 인스턴스에서 HLS 스트림을 재생하고 지금 재생 중 정보 (성공적으로)를 설정 중이지만 설정중인 MPNowPlayingInfoCenter의 속성에는 액세스 할 수 없습니다.개별 MPNowPlayingInfoCenter 속성 가져 오기/업데이트

AVAudioSessioncategoryactive 상태이며 문제가없는 receiving remote control events입니다.

NSMutableDictionary *properties = [[NSMutableDictionary alloc] init]; 
[properties setObject:title forKey:MPMediaItemPropertyTitle]; 
// Set several other properties 

MPNowPlayingInfoCenter *center = [MPNowPlayingInfoCenter defaultCenter]; 
[center setNowPlayingInfo:properties]; 

// Works! The lock screen successfully shows the title and other properties 

NSLog("%@", [center nowPlayingInfo]); 

NSLog 인쇄 만 MPNowPlayingInfoPropertyPlaybackRate0의를 포함하는 아주 기본적인 사전 - 오디오 다시 로그 동안 재생 어쨌든 정확하지 않습니다.

retrieve the currently-set dictionary of properties으로 업데이트하고 몇 개를 업데이트하고 다시 설정합니다 (앨범 아트 업데이트, 재생/일시 중지 시간 등). 우리는 무엇을 놓치고 있습니까?

답변

0

현재 속성을 검색하려면 다음을 시도하십시오.

NSMutableDictionary *playInfo = [NSMutableDictionary dictionaryWithDictionary:[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo] ; 

다음과 같이 속성을 설정/업데이트하십시오.

[playInfo setObject:[NSNumber numberWithFloat: 1.0f] forKey:MPNowPlayingInfoPropertyPlaybackRate]; 
[playInfo setObject:[NSNumber numberWithDouble:songDuration] forKey:MPMediaItemPropertyPlaybackDuration]; 

[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = playInfo; 
+0

감사합니다 @ MDB983-하지만 이것은 위의 처음 6 행에서 값을 설정하는 것과 같은 접근 방식입니다. 코드 뒤에'[[MPNowPlayingInfoCenter defaultCenter] nowPlayingInfo]'를 로깅 할 때, 전체 기능 세트를 출력 할 수 있습니까? – jterry

+0

코드에서 중단 점을 검사 할 수 있습니다. 그렇습니다. playInfo는 여러 키/값 쌍을 표시합니다. 분명히 이들은 이전에 설정 한 값입니다. – MDB983

+0

여기에 로그 플레이어가 있습니다. 정보 { MPNowPlayingInfoPropertyPlaybackRate = 1; artist = "Corinne Bailey Rae"; artwork = ""; playbackDuration = "215.4579591836735"; title = "기록을 남깁니다"; } 이러한 속성은 모두 이전에 다른 곳에서 설정되었습니다. – MDB983