2011-10-19 2 views
1

저는 동영상 재생을 위해 lwuit videocomponent를 사용하고 있습니다. 비디오를 표시 폼에서 다시 다른 형태로 전환 (즉 loginform) (즉 videoform가), 비디오가 loginform의 상단에 재생 될 때동영상 구성 요소가 중지되지 않습니다.

import com.sun.lwuit.Button; 
import com.sun.lwuit.Display; 
import com.sun.lwuit.Font; 
import com.sun.lwuit.Form; 
import com.sun.lwuit.Image; 
import com.sun.lwuit.VideoComponent; 
import com.sun.lwuit.animations.CommonTransitions; 
import com.sun.lwuit.events.ActionEvent; 
import com.sun.lwuit.events.ActionListener; 
import com.sun.lwuit.plaf.Border; 
import com.sun.lwuit.table.TableLayout; 
import javax.microedition.midlet.*; 

public class vtestMidlet extends MIDlet implements ActionListener{ 
    private Image back; 
    public void startApp() { 
     Display.init(this); 
     loginform(); 
    } 

    public void pauseApp() { 
    } 

    public void destroyApp(boolean unconditional) { 
    } 

    void loginform() 
    { 

     Form login=new Form(); 
     Button save; 
     save=new Button("Save"); 
     login.addComponent(save); 
login.getSelectedStyle().setBgColor(0xff0000); 
login.getUnselectedStyle().setBgColor(0xff0000); 
     save.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent ae) { 
      videoform(); 
      } 
     }); 

     login.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 200)); 
     login.show(); 

    } 

    void videoform() 
    { 
     final Form videoplayer; 
     final VideoComponent vc; 
     Button home; 

     try{ 
     videoplayer=new Form(); 
     TableLayout layout2 = new TableLayout(10,1); 
     videoplayer.setLayout(layout2); 

     vc = VideoComponent.createVideoPeer("http://localhost/md.3gp"); 

     home=new Button("Home"); 
     vc.start(); 

     videoplayer.getUnselectedStyle().setBgImage(back); 
     videoplayer.getSelectedStyle().setBgImage(back); 
     home.getUnselectedStyle().setBgColor(0x4673aa); 
     home.getSelectedStyle().setBgColor(0x4673aa); 

     home.getUnselectedStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_PLAIN, Font.SIZE_MEDIUM)); 
     home.getSelectedStyle().setFont(Font.createSystemFont(Font.FACE_PROPORTIONAL,Font.STYLE_BOLD, Font.SIZE_MEDIUM)); 
     home.getUnselectedStyle().setFgColor(0xffffff); 
     home.getSelectedStyle().setFgColor(0xffffff); 
     home.getSelectedStyle().setBorder(Border.createEmpty()); 
     home.getUnselectedStyle().setBorder(Border.createEmpty()); 
     home.getSelectedStyle().setPadding(3, 3, 6, 6); 
     home.getUnselectedStyle().setPadding(3, 3, 6, 6); 

     videoplayer.addComponent(vc); 
     videoplayer.addComponent(home); 

     videoplayer.setTransitionOutAnimator(CommonTransitions.createSlide(CommonTransitions.SLIDE_HORIZONTAL, false, 200)); 

     home.addActionListener(new ActionListener() { 
      public void actionPerformed(ActionEvent ae) { 
       vc.stop(); 
       loginform(); 
      } 
     }); 

     videoplayer.show(); 

     } 
     catch(Exception e) 
     { 
      e.printStackTrace(); 
     } 
    } 

    public void actionPerformed(ActionEvent arg0) { 

    } 
} 

내 문제입니다. 아래 스크린 샷을 찾으십시오. 비디오 구성 요소가 제대로 중지되지 않기 때문에

enter image description here

답변

5

이입니다. 추가하십시오 :

VideoComponent vc; 
Player player; 
vc = VideoComponent.createVideoPeer("http://localhost/md.3gp"); 
player = (Player) vc.getNativePeer(); 
player.realize(); 
vc.start(); 

와 액션 청취자의 :

player.stop(); 
vc.stop(); 
player.close(); 
loginform();