Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于封面图问题请看 #409

Open
CarGuo opened this issue Aug 30, 2017 · 30 comments
Open

关于封面图问题请看 #409

CarGuo opened this issue Aug 30, 2017 · 30 comments

Comments

@CarGuo
Copy link
Owner

CarGuo commented Aug 30, 2017

项目中默认没有提供封面图功能是因为之前个人使用的时候使用了fresco,所以使用了外部设置。

因为项目支持返回自己的布局,所以你可以继承后返回自己的布局来内置封面图,然后在子类加上自己的逻辑。别忘了在全屏接口也设置上你自定义的功能哟

@JeffrayZ
Copy link

请问有提供获取视频第一帧图像做封面的功能吗?

@CarGuo
Copy link
Owner Author

CarGuo commented Aug 31, 2017

没有,这个你可以通过原生api或者第三方库直接获取,并不麻烦。

@Chenayi
Copy link

Chenayi commented Sep 1, 2017

请问有什么方法或者第三方库能获取网络视频的第一帧呢

@CarGuo
Copy link
Owner Author

CarGuo commented Sep 3, 2017

SampleCoverVideo 增加了封面图的正确使用方式之一~

@CarGuo
Copy link
Owner Author

CarGuo commented Sep 3, 2017

DetailMoreTypeActivity 增加了获取视频第一帧的demo

@CarGuo
Copy link
Owner Author

CarGuo commented Sep 4, 2017

获取视频第一帧,其实glide已经封装过了MediaMetadataRetriever,可以参考下或直接使用。
对应

Glide.with(this.getApplicationContext())
                .setDefaultRequestOptions(
                        new RequestOptions()
                                .frame(1000000)
                                .centerCrop()
                                .error(R.mipmap.xxx2)
                                .placeholder(R.mipmap.xxx1))
                .load(url)
                .into(coverImageView);

VideoBitmapDecoder.java

@673295195
Copy link

你好,根据你的方法获取到了第一帧,但是前提要下载视频, 有像今日头条那样,不下载获取第一帧的方法吗

@g19980115
Copy link

@673295195 如果视频是存在七牛云,有个api可以获取,其他云你可以看看对应文档。
七牛云实现:videoUrl?vframe/jpg/offset/0

@673295195
Copy link

@g19980115 你好,目前应该是放在自己的服务器

@g19980115
Copy link

@673295195 那这个要你们服务端实现

@gaoguanqi
Copy link

请问到底如何设置封面图呢?为什么视频封面是黑色的额

@Rabbit95
Copy link

请问到底如何设置封面图呢?为什么视频封面是黑色的额

请问你的问题解决了吗,我跟你遇到了同样的问题,怎么设置封面都是黑的,非要点击播放后封面才会出来,封面的ImageView已经提前加载了也还是黑色的

@WWTDaoDao
Copy link

你好,有时候播放的时候会出现封面图挡住视频的情况,但是视频和声音都还在播放

@1227228155
Copy link

封面设置之后 还是黑屏 没有显示是什么原因呢?

@Rabbit95
Copy link

封面设置之后 还是黑屏 没有显示是什么原因呢?

检查imageView是否可视

@1227228155
Copy link

封面设置之后 还是黑屏 没有显示是什么原因呢?

检查imageView是否可视

谢谢 是的 封面布局设置可见 放到最后设置就可以了

@wangyikai1234567

This comment has been minimized.

@javaertj
Copy link

关于封面的问题,m3u8格式的你们就不要想用作者的那个方法了。
在onPrepared方法里稍微延迟一下调用Player的截图方法,自己压缩一下,因为截图出来图片很大,把这个图片作为封面就行了。

@wtww96
Copy link

wtww96 commented Jun 27, 2019

封面图高度怎么设置成和视频一样的高度

@Ximano
Copy link

Ximano commented Aug 21, 2019

封面设置之后 还是黑屏 没有显示是什么原因呢?

检查imageView是否可视

谢谢 是的 封面布局设置可见 放到最后设置就可以了

请问具体怎么操作,才能避免封面黑屏的情况?videoPlayer.getThumbImageView().setVisibility(View.VISIBLE);这样吗?什么时候设置为INVISIBLE?

@yangxu1210

This comment has been minimized.

@liguoyue

This comment has been minimized.

@MYaoDan

This comment has been minimized.

@hxysakura
Copy link

想问一下,像我全屏播放一个视频。这时候设置封面,通过setThumbImageView设置的封面也是全屏显示的。有没有其他方面设置封面与真正的播放区域一样大呢,就跟暂停时一样的效果。

@hahalike
Copy link

hahalike commented May 8, 2021

myvideo.getThumbImageViewLayout().setVisibility(View.VISIBLE); 在最后设置一下就出来了。内部代码初始化的时候,这个布局会被隐藏,所以我们要手动设置一下。 是缩略图ThumbImageView的父布局设置哦

ImageView iv = new ImageView(mContext);
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT);
iv.setLayoutParams(lp);
ImageLoader.loadImage(mContext,data.getThumbImage(),iv);
myvideo.setThumbImageView(iv);
......
myvideo.getThumbImageViewLayout().setVisibility(View.VISIBLE);

@syusikoku
Copy link

你好,我用这种方式想展示视频第一帧图片,没有效果
ImageView imageView = new ImageView(this);
coverPlayeView.setThumbImageView(imageView);
coverPlayeView.setThumbPlay(true);
// 加载在线视频
coverPlayeView.setUp(url, true, "");

@syusikoku
Copy link

你好,我更换了方式,这种也没有效果
ImageView imageView = new ImageView(this);
Glide.with(this.getApplicationContext())
.setDefaultRequestOptions(
new RequestOptions()
.frame(1000000)
.centerCrop())
.load(url)
.into(imageView);
coverPlayeView.setThumbImageView(imageView);
coverPlayeView.setThumbPlay(true);

@chuanguangzhu
Copy link

chuanguangzhu commented Mar 24, 2022

本地视频 用这种方式获取头桢

private Bitmap retryGetCover(String videoPath) { 
    try { 
        MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever(); 
       // AndroidQ以上 sdcard 采用沙箱机制 详细信息请看 https://developer.android.com/training/data-storage/shared/media?hl=zh-cn 
       if(SdkVersionUtils.checkedAndroid_Q() && videoPath.startsWith(ContentResolver.SCHEME_CONTENT)){ 
           metadataRetriever.setDataSource(getApplication(), Uri.parse(videoPath)); 
       } else { 
           metadataRetriever.setDataSource(videoPath); 
       } 
       Bitmap frameAtIndex = metadataRetriever.getFrameAtTime(0, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
       return Bitmap.createScaledBitmap(frameAtIndex, frameAtIndex.getWidth(), frameAtIndex.getHeight(), false);
   } catch (Exception e) { 
      return null; 
   }
}

@alphater
Copy link

你好,我更换了方式,这种也没有效果 ImageView imageView = new ImageView(this); Glide.with(this.getApplicationContext()) .setDefaultRequestOptions( new RequestOptions() .frame(1000000) .centerCrop()) .load(url) .into(imageView); coverPlayeView.setThumbImageView(imageView); coverPlayeView.setThumbPlay(true);

"frame"你检查下这个参数,这个是跳过帧,如果不知道这么设置先去除试试,我Glide是可以的。

@showdy
Copy link

showdy commented Dec 2, 2022

视频宽度小时,如何显示出封面,而不是显示黑色背景...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests