欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  技术分享

Android在线播放视频框架_网络视频播放源码下载

程序员文章站 2022-01-22 10:01:31
...

分享一个Android 播放视频的Demo、代码非常简洁、只需要两行代码就可以播放网络的视频了、非常方便、而且还支持ListView滑动播放、目前很多视频类的App都有这个功能、非常实用、下面是ListView滑动播放的截图

Android在线播放视频框架_网络视频播放源码下载


Adapter getView实现播放

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    //This is the point
    if (convertView != null && convertView.getTag() != null && convertView.getTag() instanceof VideoHolder) {
        ((VideoHolder) convertView.getTag()).jcVideoPlayer.release();
    }


    if (videoIndexs[position] == 1) {
        VideoHolder viewHolder;
        if (convertView != null && convertView.getTag() != null && convertView.getTag() instanceof VideoHolder) {
            viewHolder = (VideoHolder) convertView.getTag();
        } else {
            viewHolder = new VideoHolder();
            convertView = mInflater.inflate(R.layout.item_videoview, null);
            viewHolder.jcVideoPlayer = (JCVideoPlayerStandard) convertView.findViewById(R.id.videoplayer);
            convertView.setTag(viewHolder);
        }

        boolean setUp = viewHolder.jcVideoPlayer.setUp(
                "http://gslb.miaopai.com/stream/ed5HCfnhovu3tyIQAiv60Q__.mp4", JCVideoPlayer.SCREEN_LAYOUT_LIST,
                "嫂子快躲起来");
        if (setUp) {
            ImageLoader.getInstance().displayImage("http://img4.jiecaojingxuan.com/2016/3/14/2204a578-609b-440e-8af7-a0ee17ff3aee.jpg",
                    viewHolder.jcVideoPlayer.thumbImageView);
        }
    } else {

        TextViewHolder textViewHolder;
        if (convertView != null && convertView.getTag() != null && convertView.getTag() instanceof TextViewHolder) {
            textViewHolder = (TextViewHolder) convertView.getTag();
        } else {
            textViewHolder = new TextViewHolder();
            LayoutInflater mInflater = LayoutInflater.from(context);
            convertView = mInflater.inflate(R.layout.item_textview, null);
            textViewHolder.textView = (TextView) convertView.findViewById(R.id.textview);
            convertView.setTag(textViewHolder);
        }

    }
    return convertView;
}


build.gradle compile

dependencies {
    compile fileTree(dir: ´libs´, include: [´*.jar´])
    testCompile ´junit:junit:4.12´
    compile ´com.android.support:appcompat-v7:24.1.1´

    //required, enough for most devices.
    compile ´tv.danmaku.ijk.media:ijkplayer-java:0.6.1´
    compile ´tv.danmaku.ijk.media:ijkplayer-armv7a:0.6.1´
    
    //addon for arm64, x86, x86_64
    compile ´tv.danmaku.ijk.media:ijkplayer-arm64:0.6.1´
    compile ´tv.danmaku.ijk.media:ijkplayer-x86:0.6.1´
    compile ´tv.danmaku.ijk.media:ijkplayer-x86_64:0.6.1´
    
}


android视频播放框架源代码下载链接: android视频播放 密码: saiu