WebView不播放视频

时间:2012-11-24 10:39:24

标签: android video webview

我有一个网址,实际上这个网址显示广告所以它可能是一个img,视频。如果我们收到视频,那么onclick视频应该播放。但它没有播放。我正在使用Dell strek(2.2)。所以请建议我该如何解决这个问题。 感谢

1 个答案:

答案 0 :(得分:1)

在onCreate中设置视频播放器和URL,并通过实现onClickListener进行实际播放。

public class Test extends Activity {
    TabHost th;
    VideoView video;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        // Create tabs using XML

        video = (VideoView) findViewById(R.id.VideoView);
        String path1 = "YOUR_URL";
        MediaController mc = new MediaController(this);
        mc.setAnchorView(video);
        mc.setMediaPlayer(video);
        Uri uri = Uri.parse(path1);
        video.setMediaController(mc);
        video.setVideoURI(uri);
        Button buttonStart = (Button) findViewById(R.id.buttonStart);
        buttonStart.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                video.start();
            }

        });

    }
}

希望这会对你有所帮助。

相关问题