Yucked / Victoria

🌋 - Lavalink wrapper for Discord.NET. Provides more options and performs better than all .NET Lavalink libraries combined.
https://github.com/Yucked/Victoria/wiki
193 stars 48 forks source link

[ PROPOSAL ] Playing from stream #60

Closed ChrisVDB36 closed 4 years ago

ChrisVDB36 commented 4 years ago


Proposal Description:

Not sure if i need to ask this here.. but here i go :P Would it be possible to make the player also play music from a memory stream containing byte[] data? Like for example, i currently use victoria for all my music handling with youtube etc but I also have MP3 files stored as byte data in my database known as 'taunts' (thoose who played age of empires can remember this), but currently i make a temporary file and load that in victoria local. I messed around with the Mp3FileReader class from naudio and there it is possible to play from a stream but its messy to use and to combine this with victoria becomes pretty messy (currently doing that but ehh) Could it be possible that Victoria can do something simular as naudio so I can somehow send a stream to the player and it will play it? I would appriciate this a lot

if my suggestion is not clear enough feel free to ask info have a nice week

Yucked commented 4 years ago

In your Lavalink application.yml check if local: false is set to true then use LavaNode#SearchAsync and pass in the path where the file is located at so for example: node.SearchAsync("C:/Users/Yucked/Music/Bruh.mp3");

ChrisVDB36 commented 4 years ago

In your Lavalink application.yml check if local: false is set to true then use LavaNode#SearchAsync and pass in the path where the file is located at so for example: node.SearchAsync("C:/Users/Yucked/Music/Bruh.mp3");

Hey, merry christmas :D and thanks for your response. I use the local setting at the moment and I currently create a temp. file from the byte[] data i have stored for each mp3 in my database, then i use this path to give to lavalink which works perfect but my program to control my bot (made in wpf) can play sound via memory stream using naudio and I found it interesting trying this out for my bot aswell, going away from the file creating, and now recently my friend is using my bot aswell but he has no access over file creation on the host he is using (sadly) and he does not want to leave that host so he asked me if i somehow could make that possible but I cannot find any way to 'trick' lavalink into thinking its a valid url or track using memory stream, and mixing naudio with victoria/lavalink is just too much hassle Thats why I asked this here, i know its a bit overwork, but i like new things and trying to find more, thinking this could be something somewhat usefull if people want to play via byte[] data smashed in a memorystream. But offcourse if u think its too much to do then nevermind. Afterall its still your project, i can only suggest :P

Have a nice day!

Yucked commented 4 years ago

Merry Christmas to you too!

If I'm following this correctly, you've mp3 files stored as byte array in your database and you wanna play that via Lavalink? If so, Lavalink does not accept file streams or streams of any kind. You need to send a valid track hash to Lavalink in PlayPayload and Lavalink will manually load the track and stream it to Discord on your behalf. You'd have to talk to Lavalink owner and ask them to add such functionality or accept byte arrays in play payloads.

ChrisVDB36 commented 4 years ago

Hey,

Yes, correct, I have MP3 files stored in my database as byte array which I would like to play via a memory stream rather then having to create a temporary file on disk. As far as this is possible offcourse. I will go ask the owner of lavalink if he wants to consider doing this, hopefully, cause I would try it out but I dont understand so well yet how lavalink was made or victoria, im starting to get used to it and i build myself a fully working music service using victoria/lavalink but thats as far as my knowlegde goes atm :P Thanks for the responds, have a nice week

Yucked commented 4 years ago

Think of Lavalink as Discord and Victoria as Discord.NET. Victoria is just a wrapper around Lavalink.

Also, another way of doing this would be to upload the files to a direct mp3 hosting site and saving those links to database so you can easily send them to lavalink.