Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.microedition.media.Manager;
- import javax.microedition.media.Player;
- import javax.microedition.media.control.VideoControl;
- import javax.microedition.media.control.VolumeControl;
- import net.rim.device.api.ui.UiApplication;
- import net.rim.device.api.ui.component.ButtonField;
- import net.rim.device.api.ui.component.Dialog;
- import net.rim.device.api.ui.component.EditField;
- import net.rim.device.api.ui.container.MainScreen;
- public class MyRadio extends UiApplication
- {
- public static void main(String[] args)
- {
- MyRadio app = new MyRadio();
- app.enterEventDispatcher();
- }
- public MyRadio()
- {
- AudioScreen screen = new AudioScreen();
- pushScreen( screen );
- }
- }
- class AudioScreen extends MainScreen
- {
- /* player */
- Player player;
- VolumeControl vc;
- VideoControl videoControl;
- EditField _editUrl = new EditField( "Shoutcast Url: ", "http://67.159.41.241:80" );
- public AudioScreen()
- {
- /* URL a transmitir */
- String url = "";
- add ( _editUrl );
- add ( new ButtonField("Play")
- {
- protected boolean navigationUnclick(int status, int time)
- {
- play();
- return true;
- }
- });
- add ( new ButtonField("Pause")
- {
- protected boolean navigationUnclick(int status, int time)
- {
- pause();
- return true;
- }
- });
- add ( new ButtonField("Stop")
- {
- protected boolean navigationUnclick(int status, int time)
- {
- stop();
- return true;
- }
- });
- }
- // ** PLAYER
- private void play()
- {
- try
- {
- player = Manager.createPlayer( _editUrl.getText() + ";deviceside=true" );
- if ( player != null )
- {
- player.realize();
- player.start();
- }
- else
- {
- Dialog.alert( "Error al iniciar el reproductor!" );
- }
- }
- catch (Exception e)
- {
- System.out.println( e.getMessage() );
- }
- }
- private void pause()
- {
- try
- {
- if ( player != null && player.getState() == Player.STARTED )
- {
- player.stop();
- }
- else
- {
- Dialog.alert( "Error al pausar el reproductor!" );
- }
- }
- catch (Exception e)
- {
- System.out.println( e.getMessage() );
- }
- }
- private void stop()
- {
- pause();
- player = null;
- }
- public boolean onClose()
- {
- stop();
- return super.onClose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement