最近做项目的时候在android studio的控制台总是能看到 MediaPlayer info/warning (3,0) 的日志输出。然后我就进入MediaPlayer源码中看了看。
/** The player just pushed the very first video frame for rendering.
* @see android.media.MediaPlayer.OnInfoListener
*/
public static final int MEDIA_INFO_VIDEO_RENDERING_START = 3;
按照他们源码的意思,0表示没有问题。3表示mediaplay对视频的第一帧进行了渲染。。。触发这个的代码应该是我对视频进行了截图操作吧,也就是以下的代码
String sourcePath = mStorePath;//视频路径
//将视频资源硬解码出来
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(sourcePath);
Bitmap bitmap = retriever.getFrameAtTime(1000L);//获取视频的指定帧,ps:这里的单位是纳秒