[Java] Youtube Player for your bot

java
download
youtube

#21

The player is using an “Iframe” (like a java equivalent of one) that’s based on your OS’s browser. On windows that’s IE, on mac it’s safari. Go try the url in your IE and see how it responds. I’m able to bring pretty much any page in the player without issues…


#22

Version 1.1.0.0

A.K.A: The one where I break more things than I fix.

You might notice the new files are smaller than they used to be. Why is that? Well, I’ve stopped using the Eclipse SWT library and opted for one more native to Java, JavaFX. This is realistically my first time using JavaFX, so I expect issues to arise.

Everything should be the exact same, though the player might look a tad bit different to you.

As always, be sure to report all bugs on this thread so I can solve them faster.

Edit:

There is a known bug in 1.1.0.0 where the volume set by your player is essentially ignored and the application will use it’s own volume. I’m trying everything I can think of to fix this but nothing seems to work correctly.


#23

Version 1.1.0.1

The one where nothing changes.

In this version I attempted to introduce a mechanic to try and control the volume (which as mentioned in my previous post is bugged). I’m pretty sure it didn’t actually fix anything but, I mean, here’s to hoping?

I also removed some code that was no longer needed as I found a better way to handle things.

Not-So-Fun Fun-Fact: Did you know that JavaFX and Java Swing run on separate threads even if they’re in the same application? Yeah. Well, they do.


#24

Version 1.1.0.2

The one where I include cheap hacks to upset everyone.

As you can see there’s some nifty new buttons added to the interface. I’ll describe them starting with Chat and ending with the expanded combo box.

Chat Button: This button toggles the youtube player’s Chat OUTPUT. This does not bring up a chatbox into the player. If the button is green, output is enabled. If the button is red, output is disabled. Chat output includes things like announcing the currently playing song.

Song Reqs Button: Similar to the chat button, but instead this toggles Song Requests on or off. Again, if the button is GREEN, song requests are enabled. If the button is RED, they are disabled.

Random Button: This button will toggle the status of the playlist randomizer. At this point you can probably guess, GREEN means it’s enabled and RED means it’s disabled.

default combo box (the thing with my mouse on it): This is the player resizer. This feature only works on phantombot 2.4.0 with my modifications below. If you attempt to use this feature otherwise… it probably won’t work or will break something (not my fault I said not to use it!).

Making the Combo Box Work!

This is a very simple edit in order to make the resizer combo box to work.

  1. Open \web\ytplayer\js\index.js in Notepad++ (Notepad will work but it’s the devil) or another rich text editor.

  2. Scroll to the very bottom and find this:

    // Set the player div size here.
    $(function() {
     let size = localStorage.getItem('phantombot_ytplayer_size');
     switch (size) {
         case 'half':
             $('#left-section').attr('class', 'col-md-6');
             $('#right-section').attr('class', 'col-md-6');
             break;
         case 'small':
             $('#left-section').attr('class', 'col-md-5');
             $('#right-section').attr('class', 'col-md-7');
             break;
         case 'tiny':
             $('#left-section').attr('class', 'col-md-4');
             $('#right-section').attr('class', 'col-md-8');
             break;
         default:
             $('#left-section').attr('class', 'col-md-7');
             $('#right-section').attr('class', 'col-md-5');
     }
    });
    
  3. Replace all that nonsense with this:

     // Set the player div size here.
     function setSize() {
     let size = localStorage.getItem('phantombot_ytplayer_size');
     switch (size) {
     case 'half':
         $('#left-section').attr('class', 'col-md-6');
         $('#right-section').attr('class', 'col-md-6');
         break;
     case 'small':
         $('#left-section').attr('class', 'col-md-5');
         $('#right-section').attr('class', 'col-md-7');
         break;
     case 'tiny':
         $('#left-section').attr('class', 'col-md-4');
         $('#right-section').attr('class', 'col-md-8');
         break;
     default:
         $('#left-section').attr('class', 'col-md-7');
         $('#right-section').attr('class', 'col-md-5');
        break;
     }
     }
     setSize();
    
  4. Save your changes.

  5. Enjoy the new features.

As always, be sure to report all bugs on this thread so I can solve them faster.

And a huge thank you to all that download/support.