This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jan 26th, 2013  |  syntax: None  |  size: 3.50 KB  |  views: 25  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. player = Manager.createPlayer("rtsp://v1.cache5.c.youtube.com/CjYLENy73wIaLQm8E_KpEOI9cxMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYLm0hv_ig5HRTww=/0/0/0/video.3gp");              
  2.  
  3.                   //A player listener is needed so that we know, when the video has reached the END_OF_MEDIA position
  4.             player.addPlayerListener(this);
  5.             player.realize();
  6.             player.prefetch();
  7.  
  8.           //The duration of the video
  9.             duration = player.getDuration();
  10.  
  11.             //The video control instance is created and attached to this Canvas in Full SCreen mode
  12.             vc = (VideoControl)player.getControl("VideoControl");
  13.  
  14.             voc = (VolumeControl)player.getControl("VolumeControl");
  15.             voc.setLevel(100);
  16.             voc.setMute(false);
  17.  
  18.  
  19.             vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this);
  20.             vc.setDisplaySize(240, 196);
  21.             //vc.setDisplayFullScreen(true);
  22.  
  23.             vc.setVisible(true);
  24.  
  25.  
  26.  
  27.  
  28.  
  29.            // vc.setDisplayFullScreen(true);
  30.             //next time the above operations will be skipped
  31.             firstPlay = false;
  32.  
  33.           //A new thread handles the move of the cursor while the video progresses.
  34.             //The thread is distroyed when the video is stopped.
  35.             thread = new Thread(this);
  36.             thread.start();
  37.        
  38. import javax.microedition.lcdui.*;
  39. import javax.microedition.midlet.*;
  40. import javax.microedition.media.*;
  41. import javax.microedition.media.control.VideoControl;
  42.  
  43. public class RTSPFullScreen extends MIDlet implements CommandListener, PlayerListener {
  44.  
  45.     private Display d;
  46.     private Player p;
  47.     private Canvas c;
  48.     private Command exitCommand = new Command("Exit", Command.EXIT, 1);
  49.     VideoControl vc;
  50.  
  51.     public RTSPFullScreen() {
  52.  
  53.         d = Display.getDisplay(this);
  54.  
  55.  
  56.     }
  57.  
  58.     public void startApp() {
  59.         c = new Canvas() {
  60.  
  61.             protected void paint(Graphics g) {
  62.  
  63.                 g.setColor(0, 0, 0);
  64.                 g.fillRect(0, 0, getWidth(), getHeight());
  65.  
  66.  
  67.             }
  68.         };
  69.  
  70.         c.setFullScreenMode(true);
  71.         c.addCommand(exitCommand);
  72.         c.setCommandListener(this);
  73.         d.setCurrent(c);
  74.  
  75.  
  76.  
  77.  
  78.         try {
  79.            p = Manager.createPlayer("rtsp://v1.cache5.c.youtube.com/CjYLENy73wIaLQm8E_KpEOI9cxMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYLm0hv_ig5HRTww=/0/0/0/video.3gp");
  80.  
  81.  
  82.             p.addPlayerListener(this);
  83.             p.start();
  84.  
  85.             vc = (VideoControl) p.getControl("javax.microedition.media.control.VideoControl");
  86.             vc.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, c);
  87.  
  88.  
  89.  
  90.         } catch (Exception e) {
  91.             showAlert("startApp: " + e.toString());
  92.         }
  93.     }
  94.  
  95.     public void commandAction(Command c, Displayable s) {
  96.         if (c == exitCommand) {
  97.             destroyApp(false);
  98.             notifyDestroyed();
  99.         }
  100.     }
  101.  
  102.     public void pauseApp() {
  103.     }
  104.  
  105.     public void destroyApp(boolean uc) {
  106.         if (p != null) {
  107.             p.close();
  108.         }
  109.     }
  110.  
  111.     public void playerUpdate(Player player, java.lang.String event, java.lang.Object eventData) {
  112.         if (player.getState() == Player.STARTED) {
  113.  
  114.             try {
  115.  
  116.                 vc.setDisplayFullScreen(true);
  117.                 vc.setVisible(true);
  118.             } catch (Exception e) {
  119.                 showAlert("playerUpdate: " + e.toString());
  120.             }
  121.         }
  122.  
  123.     }
  124.  
  125.     public void showAlert(String aAlertText) {
  126.         Alert alert = new Alert("Alert", aAlertText, null, AlertType.ERROR);
  127.         alert.setTimeout(10000);
  128.         d.setCurrent(alert);
  129.     }
  130. }
clone this paste RAW Paste Data