TS3AudioBot icon indicating copy to clipboard operation
TS3AudioBot copied to clipboard

Play Playlist from Json file

Open marv-th opened this issue 6 years ago • 11 comments

Is it possible to play an playlist from an json url? If this isn't possible it could be an very nice feature to implement that. Thanks for ur request

marv-th avatar Aug 26 '19 01:08 marv-th

Hm, how would you encode a playlist in json? Just a list of links? The first results on Google turn up a bunch of different formats.

Flakebi avatar Aug 26 '19 10:08 Flakebi

Yes. I mean you have an json syntax and this syntax can played by the bot

marv-th avatar Aug 27 '19 16:08 marv-th

That was not a yes/no question, you might want to read that again. Also I have planned to implement/support xspf and jspf (xspf in json) (see here). I think that should be be a suitable json format

Splamy avatar Sep 01 '19 16:09 Splamy

I mean an json array and in that you have following fields: url/filename, title?, cover?, id. With the id i mean, that you can specif an id for the entry and can edit or delete them.

The json array can be read by their path name or an valid url

!jsonlist read "path/url" !jsonlist start - Play, Load and Synchron the list with the bot !jsonlist stop - Stop playing the list !jsonlist repeat <on/off> - Start the Playlist again, if the last song was played. !jsonlist shuffle <on/off> - Shuffle the current playlist

An unique identifier (id) is important to set. The bot identifier the current played song and play the next song after that. If the next song is not possible the bot will be stop playing music or start it aggain if the "!jsonlist repeat" set to on. If the json file was edit the bot will be take over this automatically (before the next song will be played).

I would be try to code an plugin what exactly do this for our system (compatible with Database, ...). I would be happy if you tell me the current media stop event and give an example.

marv-th avatar Sep 04 '19 16:09 marv-th

Most of that can already be done now with the curren setup. !jsonlist read "path/url" -> !list get "path/url" !jsonlist start - !list play !jsonlist stop - !stop !jsonlist repeat <on/off> - !repeat one/off/all !jsonlist shuffle <on/off> - !shuffle on/off

the only thing that is not supported is a json format; currently supported are m3u, pls, wpl and zpl Also I don't know what you mean with id; the name already is unique

Please note that the upcomming rework for playlists will change some of that syntax

Splamy avatar Sep 05 '19 12:09 Splamy

I already know that..

First i thought its easier to handle with the id. But in this way it is not needed.

I wants to build an plugin for us, cause its easier than to connect this to an database. So can you tell me how to use the stopped after event? Maybe can give an example?

marv-th avatar Sep 05 '19 13:09 marv-th

public class NowPlaying : IBotPlugin {
    public PlayManager PlayManager { get; set; }

    public void Initialize() {
        // will be called when a song ended and the bot will try to play a new song, either from the queue or the next in the playlist
        PlayManager.BeforeResourceStopped += BeforeStop;
        // will be called when playback actually stopped
        PlayManager.AfterResourceStopped += AfterStop;
    }

    private void BeforeStop(object sender, EventArgs e) {
    }

    private void AfterStop(object sender, EventArgs e) {
    }

    public void Dispose() {
        PlayManager.BeforeResourceStopped -= BeforeStop;
        PlayManager.AfterResourceStopped -= AfterStop;
    }
}

Splamy avatar Sep 05 '19 13:09 Splamy

Thanks a lot!😃

marv-th avatar Sep 05 '19 20:09 marv-th

Is it possible, that this doesn't work anymore in the newest ts3ab version?

marv-th avatar Sep 14 '19 08:09 marv-th

Still works; have you added all namespaces?:

using System;
using TS3AudioBot;
using TS3AudioBot.Audio;
using TS3AudioBot.Plugins;
using TS3AudioBot.CommandSystem;
// ...

Splamy avatar Sep 14 '19 14:09 Splamy

problem already clarified

marv-th avatar Sep 20 '19 20:09 marv-th