Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.nelosia.radio;
- import java.io.PrintStream;
- import java.net.URL;
- import javazoom.jl.player.JavaSoundAudioDevice;
- import javazoom.jl.player.Player;
- import net.minecraft.client.Minecraft;
- public class Radio
- {
- private String streamURL = "http://streaming.radio.funradio.fr/fun-1-48-192";
- private static Player player;
- private static float volume;
- public Radio(float vol)
- {
- System.out.println("Initializing radio...");
- volume = vol;
- }
- public void startPlayer()
- {
- try
- {
- Thread t = new Thread()
- {
- public void run()
- {
- try
- {
- Radio.setbounds(new Player(new URL(Radio.this.streamURL).openStream()));
- Minecraft.getMinecraft().isRadioPlaying = true;
- JavaSoundAudioDevice.radioVolume = Radio.volume;
- Radio.player.play();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- };
- t.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- public void stop()
- {
- if ((player != null) && (isPlaying()))
- {
- volume = 0.0F;
- JavaSoundAudioDevice.radioVolume = -1500.0F;
- RadioSlider.field_146134_p = 0.0F;
- player.close();
- Minecraft.getMinecraft().isRadioPlaying = false;
- }
- }
- public boolean isPlaying()
- {
- return Minecraft.getMinecraft().isRadioPlaying;
- }
- public static void setVolume(float f)
- {
- if (player != null)
- {
- volume = f;
- JavaSoundAudioDevice.radioVolume = f * 46.0F - 40.0F;
- if (f <= 0.0F) {
- JavaSoundAudioDevice.radioVolume = -1500.0F;
- }
- }
- }
- public float getVolume()
- {
- return JavaSoundAudioDevice.radioVolume;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement