Home Loading ".mp3" background music
Reply: 0

Loading ".mp3" background music

Saurabh Sharma
1#
Saurabh Sharma Published in 2018-02-13 11:24:21Z

I wish to provide an "mp3" background sound to my loading screen when my java file is run. I would prefer if there are no external libraries like JMF or JLayer involved.
I am new to programming so please mention the steps involved in detail.

class LoadingGif {

    public LoadingGif(String gif_locn) {
        JFrame loader;
        ImageIcon load_gif;
        JLabel gif_screen;
        long load_time;

        load_time = (long) (((Math.random() * 10) % 6) * 1000);

        load_gif = new ImageIcon(gif_locn);

        gif_screen = new JLabel(load_gif);
        gif_screen.setBounds(580, 260, 210, 200);

        loader = new JFrame();
        loader.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        loader.setExtendedState(JFrame.MAXIMIZED_BOTH);
        loader.setUndecorated(true);
        loader.setVisible(true);
        loader.setAlwaysOnTop(true);
        loader.setBackground(new Color(0, 0, 0, 0));
        loader.setLayout(null);
        loader.add(gif_screen);

        try {
            if (load_time < 3000)
                load_time = 3500;
            Thread.sleep(load_time);
            loader.dispose();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}

This is the main class that launches the loading animation.

public class Launcher {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        String folder = "C:/Users/Downloads/";    
        LoadingGif load = new LoadingGif(folder + "loader.gif");
    }
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.352227 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO