Android开发,前台WebView中的JS调后台java代码,代码中实例化videoView,start方法也执行了,requestFocus方法也执行了,多线程也实现了,程序执行无错误,但页面没有跳转,请问这可能是什么问题?Android开发JSvideoView

解决方案 »

  1.   

    @Override
    public void onCommonCreate(Bundle savedInstanceState) {

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.business_layout_dzdd_spcx_vedio);
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);// 竖屏
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//横屏

    VideoView videoView = (VideoView)findViewById(R.id.videoView1);  
    //String e = "http://vipimage.sunday-mobi.com/2013/4/b3ed9fde-eedf-4c71-8dbd-e97acc5237f5.flv";
            //String path = "http://vipimage.sunday-mobi.com/2013/4/2945920e-48ac-46ae-afb6-f0c1adae2b2f.mp4";
            videoView.setVideoPath(vedioUrl);  //vedioUrl是视频地址
            videoView.setMediaController(new MediaController(this));  

    }这样你试试看  全屏播放         页面也贴给你
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/CommonLayout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
     
     <LinearLayout
            android:id="@+id/Layout_B"
              android:layout_width="wrap_content" 
             android:layout_height="wrap_content"  
             android:orientation="horizontal"
             android:layout_gravity="center"
             > 
            
          <VideoView 
                  android:layout_height="match_parent" 
                  android:id="@+id/videoView1"  
                   android:layout_width="match_parent">
              </VideoView>  
            
         </LinearLayout>
    </LinearLayout>很简单的
      

  2.   

    这是我的代码,请帮忙看看是啥问题。前台:
    function showVideo()
     {
        return window.sv.play();
    }
    后台:
    private Handler handler=null;protected void onCreate(Bundle savedInstanceState) {
        ​handler = new Handler();
        webview.addJavascriptInterface(new ShowVideo(), "sv");
    }
    class ShowVideo{
    public void play(){
    try{
    Thread t = new Thread() {
    public void run() {
    handler.post(runnableUi);
    }
    };
    t.start();
    }catch(Exception e){
    System.out.println(e.getMessage());
    }
    }
    }
    //构建Runnable对象
    Runnable runnableUi=new  Runnable(){  
    @Override  
    public void run() {
    videoView = (VideoView) findViewById(R.id.VideoView1);
    videoView.setVideoURI(Uri.parse("file:///sdcard/MyFirstAppMovie/aaa.mp4"));        
    videoView.setMediaController(new MediaController(MainActivity.this));  
    videoView.start();
    videoView.requestFocus();
    }  
    };