# Youtube Music Integration with controls

**URL:** <https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777>\
**Category:** Unapproved/Deprecated\
**Created:** [January 19, 2024, 8:21pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777 "2024-01-19T20:21:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![krak8](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/krak8/32/1325_2.png) [@krak8](https://extensions.streamer.bot/u/krak8)\
**Post date:** [January 19, 2024, 8:21pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/1 "2024-01-19T20:21:06Z")

</div>

## Description

This extension will allow you to use **Youtube Music** app with streamerbot.

- Ability to control Youtube music with streamer bot.
- Ability to fetch current playing song and last added song.

 ![screenshot.png](https://extensions.streamer.bot/uploads/default/original/2X/b/b7aaee79a8e14368a7e9217baba6863df5aa8690.png)

## Import Code

Import the following code in streamer bot.  
[ytmusic v2.sb](https://extensions.streamer.bot/uploads/short-url/objTEIprM4teP1JQpzgGVCQHM1Z.sb) (5.4 KB)

## Resources

These are the requirements for getting this to work.

- Youtube Music app from : [YTMusic fork by MrF1yn](https://github.com/MrF1yn/youtube-music/releases/latest)

Please only use the non-WebSetup version as WebSetup version does not come  
with webserver plugin

- OBS Plugin : [Tuna-OBS](https://obsproject.com/forum/resources/tuna.843/)
- Obviously StreamerBot.

## Installation

Import the [ytmusic v2.sb](https://extensions.streamer.bot/uploads/short-url/objTEIprM4teP1JQpzgGVCQHM1Z.sb) (5.4 KB) in Streamer.bot

In Streamer.bot click the `Import` button in the top menu. Drag the **.sb** file into the `Import String` field.

 ![image](https://extensions.streamer.bot/uploads/default/original/1X/054c3a1bafb02540f76da07f8b72568a01be54ec.png)

### First Step

Assuming you have the “[YTMusic fork by MrF1yn](https://github.com/MrF1yn/youtube-music/releases/latest)” app installed. `(Please use non-WebSetup version as WebSetup version doesn't have webserver plugin in it.)`

1. Open YTMusic app and on navigation bar click on `options` \> uncheck `Auto Update` (Disable auto update)  
 ![image](https://extensions.streamer.bot/uploads/default/original/2X/4/41d6c62c6e1dd627bc8f5090124bbbb77b64762e.png)

2. On the navigation bar go to `plugins` \> `webserver` & enable the plugin if its disabled.  

3. Enable Tuna plugin in YTMusic app on the navigation bar go to `plugins` \> `Tuna OBS`.  

### Second Step

Assuming you have the “[Tuna-OBS](https://obsproject.com/forum/resources/tuna.843/)” plugin installed.

1. In OBS go to `Tools` \> `Tuna Settings` & set `Song source` to `Web browser` also enable `Host/receive information on local webserver with port 1608`. (Don’t forget to start tuna and apply)  
 ![tuna2](https://extensions.streamer.bot/uploads/default/original/2X/1/1df1e8b5bdfbb3bf779756eaf853417757084da1.png)

Do not change the default webserver port or the data won’t be passes to streamer bot. Also clear your song queue and start the song with command so everything functions properly.

If you followed all the steps correctly then you are good to go. 👍

## Changelogs

### V2

> - Changed the code in Music Now Playing to not create new browser instance. (Thanks to @rondhi for giving me a new code.)
> - Updated the header name from `value` to `name` in play command.

## Configuration

These are the things you can configure with this setup.

- Play Music  
you can add music to queue and/or force play the music immediately.  
`http://localhost:8888/play` & `http://localhost:8888/video` use following headers.

- Fetch last added song  
`http://localhost:8888/lastAdded` gives the name of the last added song.

- Play / Pause Music  
`http://localhost:8888/playpause` allows you to toggle the state of music.

- Play next song or previous song

- Queue  
`http://localhost:8888/queue` gives you song queue list. (I haven’t use this)

## Commands

These are the available commands feel free to change them.

| **Command** | **Description** |
| --- | --- |
| **!p `<song name>`** | plays the song. (play) |
| **!vp `<song name>`** | plays the video song. (video play) |
| **!np** | Tells the current song name. (now playing) |
| **!pause, !resume, !stop** | Toggle the song state from play to stop or vice versa. |
| **!s** | Skips the current playing song. (skip) |

## Contributors

- Krak8 | [Socials](https://krak8.xyz)  
Check my stream : [https://twitch.tv/imKrak8](https://twitch.tv/imkrak8)

- MrF1yn : [MrF1yn (Dibyajyoti Dey) (github.com)](https://github.com/MrF1yn)

- Rondhi : The music now playing code is written by @rondhi.

This is not a production based solution but it gets the job done. If you have something to suggest feel free to do so.

If you liked this then do check my socials : [https://krak8.xyz](https://krak8.xyz)  
I also have a way to control audio output volume in OBS via StreamerBot if you want that then do let me know.

---

<div class="post-metadata">

**Author:** ![GoWMan](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/gowman/32/4_2.png) [@GoWMan](https://extensions.streamer.bot/u/GoWMan)\
**Post date:** [February 3, 2024, 8:29am UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/2 "2024-02-03T08:29:24Z")

</div>

Sadly this does not follow the [Submission Template](https://extensions.streamer.bot/t/extension-submission-template/222/4) so it can not be approved. I will leave this submission here for 30 more days to give you time to update it to follow the template. If within 30 days you don’t update it then it will auto close and will be moved to declined.

---

<div class="post-metadata">

**Author:** ![krak8](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/krak8/32/1325_2.png) [@krak8](https://extensions.streamer.bot/u/krak8)\
**Post date:** [February 3, 2024, 1:17pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/3 "2024-02-03T13:17:31Z")

</div>

I have made the changes do check if this format works. @GoWMan

---

<div class="post-metadata">

**Author:** ![pwnyy](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/pwnyy/32/2970_2.png) [@pwnyy](https://extensions.streamer.bot/u/pwnyy)\
**Post date:** [February 24, 2024, 7:00pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/4 "2024-02-24T19:00:48Z")

</div>

I’m currently checking it a bit, ~~the first thing I noticed in your instructions it says to enable the webserver in the App, however at least in the latest version I just downloaded there is no Webserver included in the plugins, so I can’t really test further atm.~~

Second in the action called Music Now Playing, you are using “using WebClient”, best case you would be creating static instance of the WebClient and in the Execute Code subaction settings “Keep Instance Active”. This way it will not create a new Webclient everytime the command is called, and uses only once WebClient instance. This might not be a big issue tho!

I’m a bit confused as to how it’s decided to which playlist the songs are getting added to? For example at the very start I tested the play/pause option, worked as intended is just played a random song, in this case it was an Imagine Dragons album. Adding songs to the queue then added the songs to that album queue. Now I thought, I’ll just create a new playlist and start playing it, then it should probably recognize that it’s playing the specific playlist and add the songs to that queue. But honestly I had no clue where the songs were getting added in the end. So maybe it’s just user error but unsure…

---

<div class="post-metadata">

**Author:** ![krak8](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/krak8/32/1325_2.png) [@krak8](https://extensions.streamer.bot/u/krak8)\
**Post date:** [February 28, 2024, 11:37am UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/5 "2024-02-28T11:37:32Z")

</div>

> _Quoted reply by @pwnyy ([Jump](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/4))_  
> Second in the action called Music Now Playing, you are using “using WebClient”, best case you would be creating static instance of the WebClient and in the Execute Code subaction settings “Keep Instance Active”. This way it will not create a new Webclient everytime the command is called, and uses only once WebClient instance. This might not be a big issue tho!

I am unfamiliar with C# and the code is made using Chat GPT. If someone can help me fix it I will make the necessary changes.

> _Quoted reply by @pwnyy ([Jump](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/4))_  
> I’m a bit confused as to how it’s decided to which playlist the songs are getting added to? For example at the very start I tested the play/pause option, worked as intended is just played a random song, in this case it was an Imagine Dragons album. Adding songs to the queue then added the songs to that album queue. Now I thought, I’ll just create a new playlist and start playing it, then it should probably recognize that it’s playing the specific playlist and add the songs to that queue. But honestly I had no clue where the songs were getting added in the end. So maybe it’s just user error but unsure…

So the songs are getting added to queue not the playlist. If you start with songs already in your queue then the songs you add will be in the last or end of the queue. I will recommend starting with empty queue so that the songs requested by the chat will be the ones playing.

---

<div class="post-metadata">

**Author:** ![GoWMan](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/gowman/32/4_2.png) [@GoWMan](https://extensions.streamer.bot/u/GoWMan)\
**Post date:** [March 2, 2024, 11:18pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/6 "2024-03-02T23:18:40Z")

</div>

Unlisted on March 2, 2024, 11:18pm UTC



---

<div class="post-metadata">

**Author:** ![GoWMan](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/gowman/32/4_2.png) [@GoWMan](https://extensions.streamer.bot/u/GoWMan)\
**Post date:** [March 3, 2024, 12:05am UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/7 "2024-03-03T00:05:14Z")

</div>

Listed on March 3, 2024, 12:05am UTC



---

<div class="post-metadata">

**Author:** ![krak8](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/krak8/32/1325_2.png) [@krak8](https://extensions.streamer.bot/u/krak8)\
**Post date:** [March 10, 2024, 12:57pm UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/8 "2024-03-10T12:57:28Z")

</div>

I have updated few things in V2 please refer to [#changelogs](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777#changelogs-7).  
Once again thanks to @rondhi for helping me with new code.

---

<div class="post-metadata">

**Author:** ![rondhi](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/rondhi/32/24_2.png) [@rondhi](https://extensions.streamer.bot/u/rondhi)\
**Post date:** [March 11, 2024, 6:03am UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/9 "2024-03-11T06:03:33Z")

</div>

You should point to [https://github.com/MrF1yn/youtube-music/releases/latest](https://github.com/MrF1yn/youtube-music/releases/latest)

As well as point out to download the non-WebSetup version because the WebSetup version does not come with the Webserver plugin.

 ![image](https://extensions.streamer.bot/uploads/default/original/2X/e/e3d918ab8ebd0b9712a1c2bde77e1011936cb1ac.png)

---

<div class="post-metadata">

**Author:** ![krak8](https://extensions.streamer.bot/user_avatar/extensions.streamer.bot/krak8/32/1325_2.png) [@krak8](https://extensions.streamer.bot/u/krak8)\
**Post date:** [March 12, 2024, 10:31am UTC](https://extensions.streamer.bot/t/youtube-music-integration-with-controls/777/10 "2024-03-12T10:31:24Z")

</div>

Oh yes I should do that thanks for the suggestions 😃
