2 years ago
#52694
Thornack
How can you Embed YouTube Video using JOGL
I am working on adding cutscenes to a game mod I am writing. The game renders GUI elements using JOGL, so I have created a render event for the Player's Heads Up Display (HUD) and I want to render an overlay on this HUD which plays an embedded youtube video and then cancel the render once the youtube video stops.
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onRender(RenderGameOverlayEvent.Post event) {
player = mc.thePlayer;
int height = event.resolution.getScaledHeight();
int width = event.resolution.getScaledWidth();
if(isVisible){
GL11.glPushMatrix();
this.mc.getTextureManager().bindTexture(texture);
drawPlayerHUD(videoCutScenePath, width, height, event);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(false);
GL11.glColor4f(1.0F, 1.0F, 1.0F, guiOpacity);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glPopMatrix();
}
}
When isVisible is set true - play cut scene from embeded youtube video inside the frame. I have access to the resolution of the frame (Height and Width), mouseX, mouseY, partialTick count and I have successfully displayed an image texture in png format on this frame already. I am looking to now render a video from youtube specifically. How would you accomplish this?
private void drawPlayerHUD(String path, int width, int height, RenderGameOverlayEvent.Post event){
//getYouTube video so the onRender method can render it??
}
[Edit] I have tried to open the Youtube URL using the following method which also returns the status for debugging purposes and this works but it opens in a new window. I now want to merge the two and am unsure how.
public static String openWebpage() {
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch_popup?v=[videoID]?&autoplay=1"));
} catch (IOException e) {
e.printStackTrace();
return "Can't open browser for some reason";
} catch (URISyntaxException e) {
e.printStackTrace();
return "Bug Detected: The URL is invalid for some reason.";
}
} else {
return "For some reason You Can't open the browser";
}
return null;
}
java
opengl
video
embedding
0 Answers
Your Answer