2012-11-06 48 views
1

我在Adobe AIR中使用Android ANE插入VideoView以觀看視頻。問題是,一旦添加視頻,屏幕的其餘部分不可點擊。WebView下的不可觸摸項目

這裏是用來插入VideoView代碼:

// File: VideoPlayerTestActivity.java 
protected void onCreate(Bundle savedInstance) 
{ 
    super.onCreate(savedInstance); // always call this 

    VideoView videoHolder = new VideoHolder(this); 
    this.programaticallyAddToLayout(videoHolder); 

    // Add the media controllers at bottom of video, instead of screen bottom 
    videoHolder.setOnPreparedListener(new OnPreparedListener() { 
     public void onPrepared(MediaPlayer mp) { 
      mp.setOnVideoSizeChangedListener(new OnVideoSizeChangedListener() { 
       public void onVideoSizeChanged(MediaPlayer mp, int width, int height) { 
        MediaController mc = new MediaController(VideoPlayerTestActivity.this); 
        videoHolder.setMediaController(mc); 
        mc.setAnchorView(videoHolder); 
       } 
      }); 
     } 
    }); 
    videoHolder.setMediaController(new MediaController(this)); 
    videoHolder.setVideoURI(Uri.parse(mediaURL)); 
    videoHolder.requestFocus(); 
    videoHolder.start(); 
} 

這裏是法programaticallyAddToLayout(),它創建了應該在XML佈局中的代碼。 (我不使用XML佈局文件,對,the app cannot find the xml file某種原因,仍然令我困惑不解):

private void programaticallyAddToLayout(VideoView videoView) 
{ 
    FrameLayout layout = new FrameLayout(this); 
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(800, 600); 
    layoutParams.gravity = Gravity.CENTER; 
    layout.setId(1); 
    layout.setLayoutParams(layoutParams); 

    videoView.setId(2); 
    layout.addView(videoView, layoutParams); 
    this.setContentView(layout); 
} 

這裏是應用程序的screengrab,以供參考:

screengrab

+0

你想要點擊哪個部分? 你想要的東西像thatbutton1.setOnClickListener(新的OnClickListener(){...}); ? –

回答

0

認沽紅色測試視頻視圖背景。視頻或佈局可能會覆蓋您的按鈕,如果可點擊= true,那麼事件不會傳播過去並按下按鈕。

+0

我會測試這個。謝謝! – dornad

0

想到如何解決這個問題的幾件事情。首先,你爲什麼要撥requestFocus()VideoView?這可能會產生不利影響。

如果這會使你VideoView背後的其他意見,可以按如下其移動到前面:

videoview.setZOrderMediaOverlay(false); 
0

我在Android 2.1及2.2有這個問題,但不是我口2.3