Skip to content

Commit

Permalink
Merge pull request #249 from zxzxwu/player
Browse files Browse the repository at this point in the history
Support SBC in speaker.app
  • Loading branch information
barbibulle authored Aug 18, 2023
2 parents b247aca + ec4dcc1 commit 6e8c44b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions apps/speaker/speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,11 @@ class FfplayOutput(QueuedOutput):
subprocess: Optional[asyncio.subprocess.Process]
ffplay_task: Optional[asyncio.Task]

def __init__(self) -> None:
super().__init__(AacAudioExtractor())
def __init__(self, codec: str) -> None:
super().__init__(AudioExtractor.create(codec))
self.subprocess = None
self.ffplay_task = None
self.codec = codec

async def start(self):
if self.started:
Expand All @@ -240,7 +241,7 @@ async def start(self):
await super().start()

self.subprocess = await asyncio.create_subprocess_shell(
'ffplay -acodec aac pipe:0',
f'ffplay -f {self.codec} pipe:0',
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
Expand Down Expand Up @@ -419,7 +420,7 @@ def __init__(self, device_config, transport, codec, discover, outputs, ui_port):
self.outputs = []
for output in outputs:
if output == '@ffplay':
self.outputs.append(FfplayOutput())
self.outputs.append(FfplayOutput(codec))
continue

# Default to FileOutput
Expand Down Expand Up @@ -708,17 +709,6 @@ def speaker(
):
"""Run the speaker."""

# ffplay only works with AAC for now
if codec != 'aac' and '@ffplay' in output:
print(
color(
f'{codec} not supported with @ffplay output, '
'@ffplay output will be skipped',
'yellow',
)
)
output = list(filter(lambda x: x != '@ffplay', output))

if '@ffplay' in output:
# Check if ffplay is installed
try:
Expand Down
Binary file added mmm.sbc
Binary file not shown.

0 comments on commit 6e8c44b

Please sign in to comment.