2017-02-05 13 views
5

私はAVPlayerを使用して、リモートURLからmp3ファイルを再生しています。 mp3の初期読み込み時間に問題がありますが、非常に遅い(約5-8秒)。
私はそれを他のサードパーティーのプレイヤーと比較して、はるかに遅く、私もアンドロイドプレイヤーと比較して、それはずっと遅いです。
はそう問題は、AVPlayer低速ロード

別の興味深い点は、mp3を再生しAVPlayer開始後、シークは(ほとんどすぐに)非常に高速であるということです。.. URL自体も、ネットワーク接続にしていないことは、プレイヤーのダウンロードを意味しています再生を開始する前にmp3ファイル全体を再生することができます。
この動作を制御できますか?理由ではない場合、他のアイデアは何ですか?

+0

おそらく関連:http://stackoverflow.com/questions/11171374/how-to-reduce-ios-avplayer-start-delay – Lukas

答えて

2

AVPlayerには、いくつかの新しい機能(iOS 10以降)があります。試してみることができます。私は自分でそれを使用し、すべてが適切に動作していた。

/*! 
@method  playImmediatelyAtRate: 
@abstract  Immediately plays the available media data at the specified rate. 
@discussion 
When the player's currentItem has a value of NO for playbackBufferEmpty, this method causes the value of rate to change to the specified rate, the value of timeControlStatus to change to AVPlayerTimeControlStatusPlaying, and the receiver to play the available media immediately, whether or not prior buffering of media data is sufficient to ensure smooth playback. 
If insufficient media data is buffered for playback to start (e.g. if the current item has a value of YES for playbackBufferEmpty), the receiver will act as if the buffer became empty during playback, except that no AVPlayerItemPlaybackStalledNotification will be posted. 
*/ 
- (void)playImmediatelyAtRate:(float)rate NS_AVAILABLE(10_12, 10_0); 

さらにあなたは(あなたがあまりにもそれのためにKVOを使用することができます)、この変数をチェックアウトすることができます:

/*! 
    @property  reasonForWaitingToPlay 
    @abstract  Indicates the reason for waiting when the value of timeControlStatus is AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate 
    @discussion 
     When the value of timeControlStatus is AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate, this property describes why the player is currently waiting. It is nil otherwise. 
     You can use the value of reasonForWaitingToPlay to show UI indicating the player's waiting state conditionally. 
     This property is key value observable. 
     Possible values are AVPlayerWaitingWithNoItemToPlayReason, AVPlayerWaitingWhileEvaluatingBufferingRateReason, and AVPlayerWaitingToMinimizeStallsReason. 
    */ 

    @property (nonatomic, readonly, nullable) NSString *reasonForWaitingToPlay NS_AVAILABLE(10_12, 10_0); 
-1

をここで、私はそれについて考える何。

異なるファイルには異なる移動アトムがあります。したがって、そのファイル内に移動アトムが最初に来た場合、このファイルはバッファリングで再生されます。このファイルはパーツとともにダウンロードされ、再生はバッファリングを続けます。

それ以外の場合、ファイル移動アトムは最後に最初の全体ファイルをダウンロードして再生します。だから私はあなたのケースだと思うのはなぜmp3全体のmp3をダウンロードするためにしばらく時間が遅れている。

このようなファイルに移動アトムを変更することができます。この回答を確認してくださいMove and fix moov atom of video recorded on phone iOS

+0

AFAIK、MP3ファイルにはMOOVアトムがありません。 MPEG4ビデオストリームに固有です。 – Jules

関連する問題