2012-04-06 87 views
0

我正在使用AVPlayer它在設備上也能正常工作,但在設備仍然在模擬器上工作時突然停止工作。我不明白爲什麼它停止工作。請檢查以下代碼AVAudio Player在設備上停止工作

NSURL *url=[NSURL URLWithString:self.urlStr]; 

    self.audioSound = [[AVPlayer alloc] init]; 

    playerItem = [AVPlayerItem playerItemWithURL:url]; 

    [playerItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil]; 

    [playerItem addObserver:self forKeyPath:@"status" options:0 context:nil]; 

    [self.audioSound replaceCurrentItemWithPlayerItem:playerItem]; 
+0

原諒如果這不是你正在發生的事情,但你的設備上的靜音開關設置爲振動?考慮到您正在使用AVPlayer。 – 2012-04-06 18:34:35

+0

您可能已經排除了它,但是您是否在更換當前產品之後播放了新產品? ('[self.audio聲音播放]') – sooper 2012-04-06 20:19:46

回答

0

我沒有看到播放視頻的任何代碼,如[player play];

你寫了這段代碼嗎?

+1

哦表,在錯誤的時候我刪除了這個....它現在工作..謝謝謝謝.... – 2012-04-09 10:14:20