yutotakano / discord-haskell-voice

A Haskell library to add voice support to discord-haskell.
https://hackage.haskell.org/package/discord-haskell-voice
MIT License
9 stars 3 forks source link

Expose the current audio's metadata #9

Open yutotakano opened 2 years ago

yutotakano commented 2 years ago

When using youtube-dl, look into exposing the current playing audio's metadata, such as title/artist. Should it make the result of --dump-json available somehow upon playing? Or a separate getMetadata function?

yutotakano commented 2 years ago

Since playYouTube etc block until they're done playing, to pass back data upon start there needs to be an MVar or something..... which could make the interface very very clunky. I'm imagining things like:

playYouTubeWith'
:: String  -- The name of the FFmpeg executable
-> (String -> [String])  -- The arguments to pass to FFmpeg
-> String -- The name of the youtube-dl executable
-> String -- The search query (or video URL)
-> MVar YouTubeData -- filled in with youtube-dl metadata upon playing
-> ConduitT ByteString ByteString (ResourceT DiscordHandler) () -- Any processing that needs to be done on the audio data
-> Voice ()

To read from the MVar, there needs to be a new forked thread..., and all-in-all it's not a good solution.

Still in search for a different method.

yutotakano commented 1 year ago

With the V2.4.0 redesign of play to take an AudioResource, and createYoutubeResource to return an AudioResource, we can now embed the audio's metadata within that datatype.