如何播放视频在ListView中像Instagram的和葡萄? [英] How Do I Play Video in ListView like Instagram and Vine?

查看:269
本文介绍了如何播放视频在ListView中像Instagram的和葡萄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的android的发展,我想在ListView播放多个视频。目前,每个列表视图行项目是VideoView。这种方法没有奏效的VideoViews出现异常时,我开始滚动。我研究过这里,的此处,<一个href="http://stackoverflow.com/questions/5896921/android-scrollview-having-videoview-is-giving-problem">here并发现VideoViews和TextureViews没有在列表视图和ScrollViews工作。是怎么样的葡萄树和Instagram的应用程序能够在列表视图播放视频?任何帮助是极大AP preciated?

I'm new to android development and I am trying to play multiple videos in a listview. Currently, each listview row item is a VideoView. This approach has not worked as the VideoViews act abnormally when I begin to scroll. I've researched here, here, here and discovered that VideoViews and TextureViews don't work well within ListViews and ScrollViews. How are apps like vine and instagram able to play videos in listviews? Any help is greatly appreciated?

推荐答案

有关播放视频列表视图中,你需要打开上的ListView项目点击视频,然后你可以检索你的视频网址字符串,如:

For playing videos in Listview, you need to open Video on Item Click of ListView then you can retrieve your video url in String like:

String  myUrl = urHashMaparraylist.get(position).get("videolocation");

现在通过这个myUrl到下一个活动,只是设置该字符串为

Now pass this myUrl to next Activity and just set this String as a

 Uri video = Uri.parse(myUrl);
 videoView.setVideoURI(video);

listView.setOnItemClickListener(new OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        String  myUrl = urHashMaparraylist.get(position).get("videolocation");
        Intent n = new Intent(YourActivityName.this , NewActivityName.class);
        n.putExtra("videolocation",myUrl);
        startActivity(n);

    }

});

现在在你的下一个活动恢复它作为一个

Now in your next Activity retrieve it as a

Uri video = Uri.parse(url);
videoView.setVideoURI(video);

在某些情况下, 设置VideoView,你可以使用:

In some case, for setting VideoView,you can use:

 android:background:"#0000"

从<一个href="http://stackoverflow.com/questions/5896921/android-scrollview-having-videoview-is-giving-problem/6832598#6832598">Android有videoview滚动型是给问题

相反VideoView,你也可以尝试使用的TextView 作为参考,你可以看到2号参考:

Instead of VideoView you can also try using TextView for reference you can see number 2 reference:

有关视频流更多的参考...你可以检查以下网址: 1> <一个href="http://developer.samsung.com/android/technical-docs/Android-Media-Streaming-Tutorial">http://developer.samsung.com/android/technical-docs/Android-Media-Streaming-Tutorial

For more reference for video streaming ... you can check the following url: 1>http://developer.samsung.com/android/technical-docs/Android-Media-Streaming-Tutorial

2> <一href="http://developer.android.com/reference/android/view/TextureView.html">http://developer.android.com/reference/android/view/TextureView.html

这篇关于如何播放视频在ListView中像Instagram的和葡萄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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