MagicMirror² v2.5.0 is available! For more information about this release, check out this topic.

ALSA sound mix problem (Youtube)


  • Module Developer

    I’m not an expert of system admin or *nix machine. So I need a help.

    Maybe it’s not a MM-specific question. Anyway,

    WHAT I WANT… :

    • playing several videos(Youtube) simultaneously in Electron / Chromium of Raspbian (Stretch)
    • I just embedded 2 youtube videos together, then tried to play both by manual.
    • When I play a video alone, it worked well.
    • But when I play 2 videos at the same time, one is not played. And system spits out this error.
    ALSA lib pcm.c:8481:(snd_pcm_set_params) Unable to set hw params for PLAYBACK: Device or resource busy
    

    Is there anyone who experienced this? Or anyone who knows how to solve this? I think it could be related with some Mixer, but I have no idea about ALSA at all.

    UPDATE
    In my research, ALSA dmix is not working properly in Raspbian Stretch (or Jessie)
    pulseaudio could be used for easy mixing, but not be included and not guaranteed to be worked in Raspbian.
    Hmmmm…


  • Module Developer

    UPDATE
    Weird thing.
    in RPI (model 3 B+ / Raspbian Stretch), in getDom() I rendered belows;

    < iframe width="560" height="315" src="https://www.youtube.com/embed/8CdcCD5V-d8" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>< /iframe>
    

    This works. but

    < audio src="test.mp3" >
    < iframe width="560" height="315" src="https://www.youtube.com/embed/8CdcCD5V-d8" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>< /iframe>
    
    

    This doesn’t work often. but I don’t know why and when.

    When audio tag exists before youtube, 100% failed. When after, sometime worked, sometime didn’t. I suspect Electron(Chromium) on RPI cannot handle multi-sound output.

    I’m rebuilding my MMM-AssistantMk2 more stable, lighter and independent from some annoying dependencies, but I’m stuck on this. I’m even considering to drop youtube features from module if I cannot solve this problem. (But who cares… 😑 )