pcm_format: AudioFormat,
) -> AsyncGenerator[tuple[bool, bytes], None]:
"""Get the audio stream for the given streamdetails as raw pcm chunks."""
- is_radio = streamdetails.media_type == MediaType.RADIO or not streamdetails.duration
- if is_radio:
- streamdetails.seek_position = 0
# collect all arguments for ffmpeg
filter_params = []
extra_input_args = []
# handle seek support
if (
streamdetails.seek_position
- and streamdetails.media_type != MediaType.RADIO
- and streamdetails.stream_type != StreamType.CUSTOM
+ and streamdetails.duration
+ and streamdetails.allow_seek
+ # allow seeking for custom streams,
+ # but only for custom streams that can't seek theirselves
+ and (streamdetails.stream_type != StreamType.CUSTOM or not streamdetails.can_seek)
):
extra_input_args += ["-ss", str(int(streamdetails.seek_position))]
return StreamDetails(
item_id=item.id,
provider=self.instance_id,
+ allow_seek=True,
can_seek=self._seek_support,
media_type=media_type,
audio_format=AudioFormat(content_type=ContentType.try_parse(mime_type)),
) -> AsyncGenerator[bytes, None]:
"""Provide a generator for the stream data."""
audio_buffer = asyncio.Queue(1)
+ # ignore seek position if the server does not support it
+ # in that case we let the core handle seeking
+ if not self._seek_support:
+ seek_position = 0
self.logger.debug("Streaming %s", streamdetails.item_id)