Search code examples
iphonecocoa-touchavfoundationavplayerlive-streaming

Is there a way to distinguish between a live stream and an on-demand file stream with AVPlayer?


I'm trying to create a more generic media controller for several types of streaming media and want to adapt the UI to the type of stream;

  • When it's an on-demand file stream (i.e. a single MP3 file that's being streamed), you should be able to seek forward and backward. Thus, the seek slider should be visible.
  • When it's a live stream, it isn't possible to seek forward and backward, and thus the seek slider should be hidden.

Is there any way to determine from the AVPlayer (or perhaps the AVPlayerItem or AVAsset) what the type of stream is?


Solution

  • It appears that this is not possible.

    However, one could check the duration of a live stream, which seems to be consistently above 33000 seconds. However, this value still fluctuates and checking for this is undesirable, since it might cause unexpected behavior.