iWheelBuy
iWheelBuy

Reputation: 5679

AVPlayer long song buffering issue

I've got an issue with long songs while using AVPlayer.

I have tested it on a 64 min song.

The issue is: when the AVPlayer buffer is full it stops playback (rate = 0.0f) and stops to download new timeRanges. When I resume playback manually it plays for some seconds and stops again. I think it continues to download new content to buffer but this process is very slow and is not suitable for gapless playback.

Is it possible to control this situation to achieve gapless playback?

Am I allowed to modify loaded time ranges (clean the buffer) during playback?

Am I allowed to increase buffer size?

Upvotes: 3

Views: 1686

Answers (1)

Segev
Segev

Reputation: 19303

Are you running it on the main thread? Try to do something like this:

#include <dispatch/dispatch.h>

dispatch_queue_t playQueue = dispatch_queue_create("com.example.playqueue", NULL);

AVAudioPlayer* player = ...
dispatch_async(playQueue, ^{
    [player play];
});

If that doesn't work I'd suggest giving OpenAL a try.

Upvotes: 3

Related Questions