从网址中Videoview视频 [英] Video from Url in Videoview

查看:160
本文介绍了从网址中Videoview视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在VideoView从URL播放视频:

I want to play a video from a url in a VideoView:

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    String path1="http://commonsware.com/misc/test2.3gp";
    Uri uri=Uri.parse(path1);

    VideoView video=(VideoView)findViewById(R.id.videoView1);
    video.setVideoURI(uri);
    video.start();
}

但我得到一个NullPointerException异常,当我尝试运行应用程序。

But I'm getting a NullPointerException when I try to run the app.

在logcat中说,问题是: video.setVideoURI(URI);

The logcat says that the problem is in: video.setVideoURI(uri);

有人能帮助我吗?

感谢。

推荐答案

我不明白,你要定义一个布局...我想你忘记了:

I don't see where you are defining a layout... I think you forgot:

setContentView(R.layout.main);

这将导致任何findViewById()返回NULL。

Which would cause any findViewById() to return null.

这篇关于从网址中Videoview视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆