Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline <audio> tag #183

Open
kousu opened this issue Dec 13, 2018 · 1 comment
Open

Inline <audio> tag #183

kousu opened this issue Dec 13, 2018 · 1 comment

Comments

@kousu
Copy link

kousu commented Dec 13, 2018

I would like ympd to be the only UI I need to offer to users in my house. I have mpd configured to be streaming-only, and these days the <audio> tag is super slick and pretty reliable so I feel like we should be able to do an all-in-one thing these days!

Here's my mpd.conf, based on the default sample, so probably it's what most people are also running:

$ cat /etc/mpd.conf 
# See: /usr/share/doc/mpd/mpdconf.example

pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"

audio_output {
       type            "httpd"
       name            "radio"
       encoder         "vorbis"                # optional, vorbis or lame
       port            "8000"
       bind_to_address "0.0.0.0"               # optional, IPv4 or IPv6
       quality         "6.0"                   # do not define if bitrate is defined
       format          "44100:16:1"
       max_clients     "50"                     # optional 0=no limit
}

I would like to add

<audio src=":8000"></audio>

Somewhere in index.html and have it play.

There's a few subtleties about this:

  1. that URL is impossible.
    • So maybe add an endpoint that proxies /stream/ -> localhost:8000, and rewrite the player as <audio src="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/stream"></audio>
    • Or maybe it can ask MPD for its list of open stream ports and set the stream URL dynamically
  2. It should probably be <audio src=":8000" controls></audio>, but that will add a bunch of buttons to the UI that will collide with the pre-existing ympd controls, and it will be easy to confuse the client <audio> controls with ympd's pre-existing play/pause/stop/skip/volume controls. What does everyone think? Should we hide the <audio> controls and instead control it indirectly (via javascript) (e.g. just set volume to the max and make it play iff mpd is playing)?
  3. I want to be able to give people a link to ympd and have it Just Work, so it should also say ``<audio ... autoplay>`, but playing continuously is tricky:
    • When mpd runs out of tracks or is paused, it shuts down the http stream, and most players (VLC, mplayer, etc) need to be manually reset. Firefox too. It would be good if there was a setInterval() wrapped around it to try to reconnect every so often.
    • While experimenting I ran into caching glitches. I managed to get Firefox into a state where it only played the same 17 seconds over and over again, even after turning off caching in developer tools. Strangely, opening a tab in the same process to https://mpdbox.local:8000 worked perfectly, so it's just something
@zuglufttier
Copy link

3. I want to be able to give people a link to ympd and have it Just Work, so it should also say ``<audio ... autoplay>`, but playing continuously is tricky:
   
   * When mpd runs out of tracks or is paused, it shuts down the http stream, and most players (VLC, mplayer, etc) need to be manually reset. Firefox too. It would be good if there was a `setInterval()` wrapped around it to try to reconnect every so often.

Did you see this? https://www.musicpd.org/doc/html/user.html#config-audio-output
There is an option always_on for audio outputs that may solve at least that problem ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants