Skip to content

Add the introductory video with captivating lore elements #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SEM24 opened this issue Jun 5, 2023 · 0 comments
Open

Add the introductory video with captivating lore elements #43

SEM24 opened this issue Jun 5, 2023 · 0 comments
Labels
feature freazed Currently not possible to implement story

Comments

@SEM24
Copy link
Owner

SEM24 commented Jun 5, 2023

NEW OPTION
Instead of video, create the class that will have several images (so it will be like slideshow) with bg music and
draw that images(create them in photoshop/sony vegas) to show the "lore" of game. Also use transactional method to change the images like "fade out".

OLD OPTION
Use long enter press to skip the video.
Tips
Tips
Tips

ChatGPT Tips:

To display a video as the first screen of your Java Swing application, you can use a JFrame to create the main window and a JLabel to display the video. You can then use a library like vlcj or JMF to play the video. Here's an example of how you can achieve this:

  1. First, make sure you have the necessary libraries in your project. You can add them as dependencies using your preferred build tool (e.g., Maven or Gradle). For example, if you're using Maven, add the following dependencies to your pom.xml file:

  2. Create a new class, let's say VideoPlayer, that extends JFrame and contains a JLabel for displaying the video. Add the necessary imports:

java
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayerComponent;

import javax.swing.;
import java.awt.
;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class VideoPlayer extends JFrame {
private final EmbeddedMediaPlayer mediaPlayer;

public VideoPlayer(String videoPath) {
    // Set up the main window
    setTitle("Video Player");
    setSize(800, 600);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create the media player component
    EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
    mediaPlayer = mediaPlayerComponent.getMediaPlayer();

    // Add the media player component to the frame
    Container contentPane = getContentPane();
    contentPane.add(mediaPlayerComponent, BorderLayout.CENTER);

    // Play the video
    mediaPlayer.playMedia(videoPath);

    // Add a window listener to stop the player and close the application when the window is closed
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            mediaPlayer.stop();
            mediaPlayer.release();
            super.windowClosing(e);
        }
    });
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        // Replace "path/to/video.mp4" with the actual path to your video file
        VideoPlayer player = new VideoPlayer("path/to/video.mp4");
        player.setVisible(true);
    });
}

}

  1. Replace "path/to/video.mp4" with the actual path to your video file in the main method.

  2. Compile and run the application. The video should start playing automatically, and the application window will close when the video finishes or when the user closes the window.

Make sure to replace "path/to/video.mp4" with the actual path to your video file. Also, ensure that you have the necessary codecs and dependencies installed for video playback to work correctly.

If you prefer not to use any external libraries, you can use the built-in support for playing videos in Java Swing using the JEditorPane class. Here's an example of how you can achieve this:

java
import javax.swing.;
import java.awt.
;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

public class VideoPlayer extends JFrame {
private JEditorPane editorPane;

public VideoPlayer(String videoPath) {
    // Set up the main window
    setTitle("Video Player");
    setSize(800, 600);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create the editor pane
    editorPane = new JEditorPane();
    editorPane.setEditable(false);
    editorPane.setContentType("text/html");

    // Load the video HTML into the editor pane
    try {
        File videoFile = new File(videoPath);
        String videoURL = videoFile.toURI().toURL().toString();
        editorPane.setText("<html><body><video src='" + videoURL + "' autoplay></video></body></html>");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Add the editor pane to the frame
    Container contentPane = getContentPane();
    contentPane.add(new JScrollPane(editorPane), BorderLayout.CENTER);

    // Add a window listener to close the application when the window is closed
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            super.windowClosing(e);
            System.exit(0);
        }
    });
}

public static void main(String[] args) {
    SwingUtilities.invokeLater(() -> {
        // Replace "path/to/video.mp4" with the actual path to your video file
        VideoPlayer player = new VideoPlayer("path/to/video.mp4");
        player.setVisible(true);
    });
}

}

In this example, the JEditorPane is used to display an HTML document that contains an embedded

Make sure to replace "path/to/video.mp4" with the actual path to your video file.

Compile and run the application, and the video should start playing automatically when the application opens.

@SEM24 SEM24 moved this to TODO in Java-2D-Medieval-RPG Jun 5, 2023
@SEM24 SEM24 moved this from TODO to In Progress in Java-2D-Medieval-RPG Jun 5, 2023
@SEM24 SEM24 added help wanted Extra attention is needed freazed Currently not possible to implement labels Jun 5, 2023
@SEM24 SEM24 moved this from In Progress to TODO in Java-2D-Medieval-RPG Jun 5, 2023
@SEM24 SEM24 removed the help wanted Extra attention is needed label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature freazed Currently not possible to implement story
Projects
Development

No branches or pull requests

1 participant