2014-12-03 2 views
2

soundcloud에서 노래를 재생하는 간단한 앱을 만드는 중입니다. 하지만 몇 가지 이상한 이유는 내 애플 리케이션이 어떤 소리를 재생 못해. 코드 조각이 실행되고있는 경우 중단 점을 사용하여 검사했습니다. 하지만 코드가 실행될 때 소리가 들리지 않습니다. 나는 Sim과 Device에서 시험해 보았다.AVPlayer가 사운드를 재생하지 못합니다. iOS8

나는 내보기 내가 두 그래서 각 프레임 워크에 대한 해결 방법을 시도해 볼 수도 있습니다 추가

#import "DetailViewController.h" 
@import AVFoundation; 
@import AVKit; 

이러한 프레임 워크를 가져옵니다.

이 나는 ​​시도했다 :

NSString *[email protected]"http://www.3rdeyelab.com/mp3/mp3/tailtoddle_lo.mp3"; 
NSURL *url=[NSURL URLWithString:urlstr]; 
AVPlayer *player; 
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url]; 
player = [AVPlayer playerWithPlayerItem:playerItem]; 
[player play]; 
player.actionAtItemEnd = AVPlayerActionAtItemEndNone; 

그리고 로컬 파일에 : MP3 파일 선택 올바른 목표를 가지고있다.

AVPlayerViewController *playerViewController = [[AVPlayerViewController alloc] init]; 
    playerViewController.player = [AVPlayer playerWithURL:[[NSBundle mainBundle] 
                  URLForResource:@"LongNight" 
                  withExtension:@"mp3"]]; 
    [playerViewController.player play]; 

는 모두 늘 궁극적으로 내가 사운드 클라우드에서 JSON의 repsonse에있는 URL을 연주하고 싶습니다 .. 어떤 사운드를 재생하지만 난 작은 시작으로 원했다.

미리 감사드립니다. 제 질문에 분명히 들어 있습니다.

답변

1

한번에 모든 사운드를 재생하기 전에

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlay]

설정.

관련 문제