diff --git a/_examples/xmpp_jukebox/README.md b/_examples/xmpp_jukebox/README.md new file mode 100644 index 0000000..9eeb3a4 --- /dev/null +++ b/_examples/xmpp_jukebox/README.md @@ -0,0 +1,37 @@ +# Jukebox example + +## Requirements +- You need mpg123 installed on your computer because the example runs it as a command : +[Official MPG123 website](https://mpg123.de/) +Most linux distributions have a package for it. +- You need a soundcloud ID to play a music from the website through mpg123. You currently cannot play music files with this example. +Your user ID is available in your account settings on the [soundcloud website](https://soundcloud.com/) +**One is provided for convenience.** +- You need a running jabber server. You can run your local instance of [ejabberd](https://www.ejabberd.im/) for example. +- You need a registered user on the running jabber server. + +## Run +You can edit the soundcloud ID in the example file with your own, or use the provided one : +```go +const scClientID = "dde6a0075614ac4f3bea423863076b22" +``` + +To run the example, build it with (while in the example directory) : +``` +go build xmpp_jukebox.go +``` + +then run it with (update the command arguments accordingly): +``` +./xmpp_jukebox -jid=MY_USERE@MY_DOMAIN/jukebox -password=MY_PASSWORD -address=MY_SERVER:MY_SERVER_PORT +``` +Make sure to have a resource, for instance "/jukebox", on your jid. + +Then you can send the following stanza to "MY_USERE@MY_DOMAIN/jukebox" (with the resource) to play a song (update the soundcloud URL accordingly) : +```xml + + + + + +``` diff --git a/_examples/xmpp_jukebox/xmpp_jukebox.go b/_examples/xmpp_jukebox/xmpp_jukebox.go index 17ca5ab..57137b8 100644 --- a/_examples/xmpp_jukebox/xmpp_jukebox.go +++ b/_examples/xmpp_jukebox/xmpp_jukebox.go @@ -49,7 +49,7 @@ func main() { handleMessage(s, p, player) }) router.NewRoute(). - Packet("message"). + Packet("iq"). HandlerFunc(func(s xmpp.Sender, p stanza.Packet) { handleIQ(s, p, player) }) @@ -139,7 +139,7 @@ func playSCURL(p *mpg123.Player, rawURL string) { // TODO: Maybe we need to check the track itself to get the stream URL from reply ? url := soundcloud.FormatStreamURL(songID) - _ = p.Play(url) + _ = p.Play(strings.ReplaceAll(url, "YOUR_SOUNDCLOUD_CLIENTID", scClientID)) } // TODO