add opus file format
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 24 Jan 2024 15:17:15 +0000 (16:17 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 24 Jan 2024 15:17:15 +0000 (16:17 +0100)
music_assistant/common/models/enums.py
music_assistant/server/controllers/player_queues.py
music_assistant/server/controllers/streams.py
music_assistant/server/providers/filesystem_local/base.py

index b46c0e11a4b0e415b2c7a96be0445eaafbd20923..af05b17eacd1c79ce66402f20b988e2e955798c7 100644 (file)
@@ -102,6 +102,7 @@ class ContentType(StrEnum):
     M4A = "m4a"
     M4B = "m4b"
     DSF = "dsf"
+    OPUS = "opus"
     WAVPACK = "wv"
     PCM_S16LE = "s16le"  # PCM signed 16-bit little-endian
     PCM_S24LE = "s24le"  # PCM signed 24-bit little-endian
index 7698f724f70a50f7da1d6d5cbbea289f95bc404f..10f720bfcd41b6e392ab37f43029961a56351b99 100755 (executable)
@@ -696,7 +696,6 @@ class PlayerQueuesController(CoreController):
                 idx += 1
         if next_item is None:
             raise QueueEmpty("No more (playable) tracks left in the queue.")
-        queue.index_in_buffer = next_index
         queue.next_track_enqueued = True
         return next_item
 
index 6db086343c56a700ae336d807d1596f298bb5aeb..67ddd7ce8aeb473a8a26284ed75c9868cf0ab050 100644 (file)
@@ -515,7 +515,7 @@ class StreamsController(CoreController):
         self.logger.debug(
             "Start serving audio stream for QueueItem %s to %s", queue_item.uri, queue.display_name
         )
-
+        queue.index_in_buffer = self.mass.player_queues.index_by_id(queue_item_id)
         # collect player specific ffmpeg args to re-encode the source PCM stream
         pcm_format = AudioFormat(
             content_type=ContentType.from_bit_depth(
@@ -785,7 +785,7 @@ class StreamsController(CoreController):
         seek_position: int = 0,
         fade_in: bool = False,
     ) -> AsyncGenerator[bytes, None]:
-        """Get a flow stream of all tracks in the queue."""
+        """Get a flow stream of all tracks in the queue as raw PCM audio."""
         # ruff: noqa: PLR0915
         assert pcm_format.content_type.is_pcm()
         queue_track = None
@@ -821,6 +821,7 @@ class StreamsController(CoreController):
                 queue_track.name,
                 queue.display_name,
             )
+            queue.index_in_buffer = self.mass.player_queues.index_by_id(queue_track.queue_item_id)
 
             # set some basic vars
             pcm_sample_size = int(pcm_format.sample_rate * (pcm_format.bit_depth / 8) * 2)
index 9adf176d05b4269485896ba4ada1eec15dc332fe..41bdfe31343bebbaa003816c1654f47211ee3694 100644 (file)
@@ -72,7 +72,7 @@ CONF_ENTRY_MISSING_ALBUM_ARTIST = ConfigEntry(
     ),
 )
 
-TRACK_EXTENSIONS = ("mp3", "m4a", "m4b", "mp4", "flac", "wav", "ogg", "aiff", "wma", "dsf")
+TRACK_EXTENSIONS = ("mp3", "m4a", "m4b", "mp4", "flac", "wav", "ogg", "aiff", "wma", "dsf", "opus")
 PLAYLIST_EXTENSIONS = ("m3u", "pls", "m3u8")
 SUPPORTED_EXTENSIONS = TRACK_EXTENSIONS + PLAYLIST_EXTENSIONS
 IMAGE_EXTENSIONS = ("jpg", "jpeg", "JPG", "JPEG", "png", "PNG", "gif", "GIF")