使用索爱V800开发流媒体应用程序[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

    protected void startApp() throws MIDletStateChangeException {
        myDisplay.setCurrent(myForm); 
        streamingThread = new Thread(this);
    }

    protected void pauseApp() {}

    protected void destroyApp(boolean unconditional) {
        try {
            myPlayer.stop();
            myPlayer.close();
        }
        catch( Exception e ) {
            log("Exception: " + e.toString());       
        }
    }
   
   /**
    * Inits and starts the Player for Video Streaming
    */
    private void startStreaming(){
        try{
             myPlayer = Manager.createPlayer("rtsp://MyServer/MyFile.3gp");
             myPlayer.addPlayerListener(this);
             myPlayer.realize();
              // Grab the video control and set it to the current display.
              vc = (VideoControl)myPlayer.getControl("VideoControl");
              if (vc != null) {
                myForm.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null));
                // sets the display size of the video.
                vc.setDisplaySize(120,160); 
              }         
              myPlayer.start();

         }catch(Exception e){
                log("Exception: " + e.toString());
         }

    }
  
    public void commandAction(Command c, Displayable s){
        if(c.getCommandType()==Command.EXIT){
            running=false;
            notifyDestroyed();
        }else{
            streamingThread.start();
        }
    }
   
   
     /**
      * PlayerListener Interface method, logs all player event.
      */
     public void playerUpdate(Player player, String event, Object eventData){
        log(" ** playerUpdate: " + event + " **");
      
     }

     public void log(String msg){
        System.out.println(msg);
     }
    
     public void run() {
         running=true;
         startStreaming();
         while(running){
             Thread.yield();
         }
     }    
}

本文关键:使用索爱V800开发流媒体应用程序
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top