[Java] Youtube Player for your bot

java
download
youtube

#1

The Boring Intro

Hello everyone,

One of my users wanted a tool to run their youtube player “out of browser” (you’ll see why that has quotes in a minute).

Before I continue, I want to note that another user on these forums has released a similar tool. You are more than welcome to check out their tool by clicking here.

Now, onto the program. This program creates a small browser-like window that contains only your youtube player. It actually utilizes your computers built in browser to render the page, but without all the extra nonsense browsers include. This is why I put quotes before, since it still utilizes the browser, but it’s not technically within it.

Usage & Download

  1. Download the file from my website (below)
  2. Double click the PhantomYoutube.jar file to run it.
  3. Enter the requested information.
    3.1 The youtube url must end with /ytplayer. This is simply how the player is designed, not a choice of my own. If you don’t believe me, try going to http://yourbotip:25000/ytplayer/ instead of http://yourbotip:25000/ytplayer (notice the missing /) in your browser, you’ll notice a difference.
  4. Verify the information is correct, and press “Continue”.
    4.1 The youtube interface should now load. If it does not, there is a problem with the information you input. If you’ve verified the information is correct, reply here and I’ll work with you to find a solution.
  5. Enjoy the player.

side note: After you’ve done the setup, it will create a pbplayer.txt file. Do not delete it, or you’ll have to go through this process again.

Download: Click Here

As of v1.1.0.0 the there is only one .jar download for all operating systems as the tool no longer uses SWT.

Windows Alt Downloads: Windows Standalone Exe || Windows Alt Standalone Exe || Windows Installer

The Standalone Exe and Installer were compiled with ExcelsiorJET, while the Alt Standalone was created with Launch4j. This is why there is a difference in filesize. One is a wrapper, and the other is a Ahead-of-time compiler.

Current Version: 1.1.0.2

Changing Settings After Setup

As of version 1.03 you are now able to change your settings by clicking the arrow (>) button in the bottom left corner. This will expand an option menu (which I will be building upon, submit features below). Click the Settings button. After changing anything (And closing the settings dialog), you will need to press the refresh button.

You are still welcome to edit the pbplayer.txt file. You can find the information on each variable below.

As of V1.0.5 people who have installed the player will find the settings in a native app folder. For windows it’s %APPDATA%\PhantomPlayer\ (put that in the address bar). Standalone exes and jars will still have the .txt file along side them.

username=
This is your panel username, you can find it in the botlogin.txt. It should be a value named paneluser=

password=
Much like the username, this is your panel password. Again, it can be found in the botlogin.txt for your bot, this time the value is panelpassword=

youtubesocket=
While it says socket, this is the url to your youtube player. It’s the EXACT SAME as the url you use in-browser. As stated before, the url must end with /ytplayer. Do NOT add a slash after, as that will also be invalid.

autoplay=
This controls the auto play feature (duh?). Set it to 0 for NO AUTOPLAY. Set it to 1 to enable autoplay.

As of 1.0.4 two new entries have been added:

caster=
This is typically your username; but you can use your bots name as well. This is used for sending the playlist command to your bot, so it can switch the playlist when you click the new “load” button.

webauth=
You can find this in your botlogin.txt, under the same name. Don’t be confused with the webauthro, as that’s the wrong value. This is used for sending commands and connecting to your bots API endpoints.

NOTE: Modifying any of the values in the pbplayer.txt file will require you to restart the tool for the changes to take effect.

Questions, Comments, Concerns, and Bug Reports

As with any of my releases on these forums, I do not provide support outside of the threads (meaning please don’t make a post about my tool, reply to the thread). The only exception is if the thread was time-locked, then you’re welcome to message me.

If you have any other questions, comments, concerns, ideas, or etc, please feel free to post them below.


#2

Quick Update

Just letting everyone know I’ve released an update for the program, it now has a new look (based on the phantombot logo. I’m not a designer srry).

On top of that you no longer need to edit the text file to modify your settings. As mentioned in the update post I’ll be building on the new option menu, which you can find by clicking the > button in the bottom left of the program.

click1

click2

This brings up the same settings menu from your first run, so you should be familiar with it. To hide the menu you can click <.

P.S: You’ll need to click refresh for the new settings to apply.


#3

Version 1.0.4

New Stuff

In version 1.0.4 there’s two new components found in the option menu. However, they’re used together.

On launch you’ll be prompted to enter two new values in the settings field:

New Settings

I’ve explained both fields above in the main post. But in short you want to enter your twitch username and the webauth found in your botlogin.txt. These two values allow the player to retrieve information from your bot’s database and also send commands to it (for playlist loading).

If you enter the wrong values you can open the settings as normal, but you will have to press refresh in order for the playlist box to populate with data.

This feature is still in beta as I was having issues when designing it, so if you experience any problems please let me know asap.


#4

page not loading

after refreshing it about 6 times i finaly got this (my guess is it doesnt work with new music player)

Also when editing the settings they dont re save to the text file <- fixed this by runing as admin


#5

This hasn’t been tested with the new player, no. But it’s an iframe for the most part so in theory it should work.

The page not loading might be due to the new playlist feature. While working on it I noticed that if the bot is slow to respond to the playlist request the page will hang a bit. I’m still working on a better solution to this that doesn’t require a new thread for a single operation.

As for the text file not saving: What version are you running (Since there’s literally 6 different downloads)?


#6

the file not saving was due to not running as admin so cant save in the program files directory but i fixed that as stated above :slight_smile:


#7

Right… and I can’t make the program try to elevate to admin, or at least put a warning… until I know which one you are running.


#8

im running the Windows Installer from the main post


#9

Thanks, I’ll see what I can do about it.


#10

could installing it into %appdata% folder where some thinsg install be a better location? not sure how things install myself


#11

The ExcelsiorJET installer allows you to pick where you install it to. (you have to click next, not the install option on the left)

When I compile the program it does give me an option as to where the default installation path is, so I could see if that’s possible, yes.


#12

Just tested that and yes it saves without it ran as admin :slight_smile:


#13

It was just something I overlooked because I install everything onto D:/ which doesn’t require admin permissions.

Looking into it, it doesn’t appear that there’s a way for the JET installer to change the path to appdata.

I want to redo some of my error handling and on top of that I could write a small system so the installer version is set to save outside of the installation folder.

So guess we’ll see what happens with 1.0.5.


#14

Version 1.0.5

No images in this one, sorry.

This one was more about updating the save directories and adding a better error logging system.

If you’re on a standalone version of the program (be it a jar or exe), error logs and your pbplayer.txt can be found next to your version of the player. The program unfortunately creates a new error log regardless of something being written in it, but the file name will be based on when you opened the player.

People who have installed the player will have to re-enter their info, sorry

This is because your information should now be located to a directory native to the computer. Windows it’s stored in your appdata, and error logs can be found here too.


If/when errors are generated during runtime, a pop should appear. However, since some errors can happen before the player is fully loaded, you will need to check the error logs if it will not open.

Edit:

One more thing: I changed the player to load the playlist information when you click the > button. If there is an error in your configuration a dialog will popup. Apologies if it seems spammy.


#15

Some error that happens when i open it :frowning:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
	at watson.phantom.PhantomConnect.<clinit>(PhantomConnect.java:20)
	at watson.frame.YoutubePlayer.retrievePlaylists(YoutubePlayer.java:220)
	at watson.frame.YoutubePlayer.updateVisibility(YoutubePlayer.java:304)
	at watson.frame.YoutubePlayer$1.widgetSelected(YoutubePlayer.java:92)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at watson.frame.YoutubePlayer.initialize(YoutubePlayer.java:195)
	at watson.frame.YoutubePlayer.<init>(YoutubePlayer.java:58)
	at watson.phantom.PhantomPlayer.loadCredentials(PhantomPlayer.java:153)
	at watson.phantom.PhantomPlayer.main(PhantomPlayer.java:55)
	... 5 more
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 19 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.NoClassDefFoundError: com/google/gson/Gson
	at watson.phantom.PhantomConnect.<clinit>(PhantomConnect.java:20)
	at watson.frame.YoutubePlayer.retrievePlaylists(YoutubePlayer.java:220)
	at watson.frame.YoutubePlayer.updateVisibility(YoutubePlayer.java:304)
	at watson.frame.YoutubePlayer$1.widgetSelected(YoutubePlayer.java:92)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
	at watson.frame.YoutubePlayer.initialize(YoutubePlayer.java:195)
	at watson.frame.YoutubePlayer.<init>(YoutubePlayer.java:58)
	at watson.phantom.PhantomPlayer.loadCredentials(PhantomPlayer.java:153)
	at watson.phantom.PhantomPlayer.main(PhantomPlayer.java:55)
	... 5 more
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 19 more

#16

Missing library.

Maybe he is using the latest:
http://central.maven.org/maven2/com/google/code/gson/gson/2.8.2/gson-2.8.2.jar

If that bombs, then maybe he isn’t using the latest :blush:


#17

As IO said, that’s an error because of a missing class. Which is quite interesting because I made sure they were packed.

You’re not using the installer anymore I take it? The only way org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader should be popping up is if you used one a jar file or the “Alt Standalone Exe”… because the other two weren’t compiled with eclipses JarInJar loader.


#18

sense i already had it installed i just replaced the exe with the Windows Alt Standalone Exe


#19

Yeah, don’t do that.

First off, the Alt standalone is compiled on a completely different program. It’s compiled in Launch4J, which is a wrapper for jars.

The standalone exe and installer exe are both compiled in ExcelsiorJET. If you want to manually update like that, you need to download the one compiled by JET, not Launch4J.

The installer for JET, should you choose to use it, will say “A previous version was found” bla bla… You can ignore that and install over it because all the paths and etc are the exact same, so it just replaces the application like you would anyways.

Regardless, I’ll be pushing a fix shortly for the files that are bugged out.


#20

ya i just re did it with the installer and its fine now just nothing populating still with the beta player

The drop-down with the playlists does work though


New YouTube Player for PhantomBot