captbaritone / webamp

Winamp 2 reimplemented for the browser
https://webamp.org
MIT License
10.28k stars 694 forks source link

How to set a PlayList with a few audio/video files to load default? #1108

Open lavanyadeepak opened 3 years ago

lavanyadeepak commented 3 years ago

Can some one point to a reference where I can set a playlist with a few audio/video files to load by default?

captbaritone commented 3 years ago

Check out the initialTracks property passed when constructing a new Webamp instance: https://github.com/captbaritone/webamp/blob/master/packages/webamp/docs/usage.md#construction

neofright commented 8 months ago

Check out the initialTracks property passed when constructing a new Webamp instance: https://github.com/captbaritone/webamp/blob/master/packages/webamp/docs/usage.md#construction

Can this be used to specify a file URI such as file:///bind_mount/playlist.m3u e.g.

  initialTracks: [{
    url: "file:///bind_mount/playlist.m3u"
  }],

I would love to create Docker container and put it behind a reverse http proxy that allows playing music bind mounted into to the container.

neofright commented 8 months ago

OK I answered my own question.

First off, WebAmp does not support playlists of any kind. You have to populate the json file list however you like.

Below are my unrelated explorations.

You can use the following file:/// scheme only if you disable CORS.

  initialTracks: [{
    url: "file:///path/to/a/track.mp3"
  }],

This can be done in Safari via: Menu Bar > Develop > Developer Settings > "Disable Cross-Origin Restrictions".

I quickly spun up a Docker container with nginx and the following configs:

server
{
    access_log      /etc/nginx/conf.d/nginx-access.log;
    error_log       /etc/nginx/conf.d/nginx-error.log debug;

    # location / {  # new url path
    #     alias /music; # directory to list
    #     autoindex on;
    # }

    location / {
        root /music;
        index index.html index.htm;
        autoindex on;
    }
}
version: '2.3'
services:
  nginx:
    image: nginx
    container_name: nginx
    volumes:
      - /lol/path/nginx/nginx/conf.d:/etc/nginx/conf.d
      - /lol/path/Music:/music:ro ## Share the music library as read only.
    ports:
      - "80:80"

This also suffers from the same CORS issues, but can be used when disabled e.g. by specifying a URL to your web server such as http://example.com/album/mp3.mp3.

I was playing with https://github.com/captbaritone/webamp/blob/master/examples/multipleTracks/index.html for the prototyping.

I suspect the cross origin issues could be worked around by self hosting the instance of WebAmp but I've decided its not worth any more of my time.