libvlc获取一帧_android - 从android vlc媒体播放器获取当前帧 - 堆栈内存溢出
我找到了一个非常简单,非常快速的解决方案。 只需使用TextureView而不是SurfaceView ,然后在使用getBitmap()函数播放时随时检索图像,如下所示。
public class MainActivity extends AppCompatActivity implements TextureView.SurfaceTextureListener,
org.videolan.libvlc.media.MediaPlayer.OnBufferingUpdateListener,
org.videolan.libvlc.media.MediaPlayer.OnCompletionListener,
org.videolan.libvlc.media.MediaPlayer.OnPreparedListener,
org.videolan.libvlc.media.MediaPlayer.OnVideoSizeChangedListener {
private AppCompatActivity me = this;
private MediaPlayer mMediaPlayer;
private TextureView mTextureViewmTextureView;
private String mUrl = "/storage/emulated/0/videos/test.mp4";
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_main);
mMediaPlayer = new MediaPlayer(VLCInstance.get());
mTextureViewmTextureView = (TextureView) findViewById(R.id.player);
mTextureView.setSurfaceTextureListener(this);
}
private void attachViewSurface() {
final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
mMediaPlayer.setScale(0);
vlcVout.detachViews();
vlcVout.setVideoView(mTextureView);
vlcVout.setWindowSize(mTextureView.getWidth(), mTextureView.getHeight());
vlcVout.attachViews();
mTextureView.setKeepScreenOn(true);
}
private void play(String path) {
try {
Media media;
if (new File(path).exists()) {
media = new Media(VLCInstance.get(), path);
} else {
media = new Media(VLCInstance.get(), Uri.parse(path));
}
mMediaPlayer.setMedia(media);
mMediaPlayer.play();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
attachViewSurface();
if (mMediaPlayer.hasMedia())
mMediaPlayer.play();
else
play(mUrl);
}
public Bitmap getImage() {
return mTextureView.getBitmap();
}
}
VLCInstance.java:
import android.content.Context;
import android.util.Log;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.util.VLCUtil;
public class VLCInstance {
public final static String TAG = "VLC/Util/VLCInstance";
private static LibVLC sLibVLC = null;
/** A set of utility functions for the VLC application */
public synchronized static LibVLC get() throws IllegalStateException {
if (sLibVLC == null) {
final Context context = VLCApplication.getAppContext();
if(!VLCUtil.hasCompatibleCPU(context)) {
Log.e(TAG, VLCUtil.getErrorMsg());
throw new IllegalStateException("LibVLC initialisation failed: " + VLCUtil.getErrorMsg());
}
try{
sLibVLC = new LibVLC(context);
}catch (Throwable e){
e.printStackTrace();
}
}
return sLibVLC;
}
public static synchronized void restart(Context context) throws IllegalStateException {
if (sLibVLC != null) {
sLibVLC.release();
sLibVLC = new LibVLC(context);
}
}
}
libvlc获取一帧_android - 从android vlc媒体播放器获取当前帧 - 堆栈内存溢出相关推荐
- 【媒体应用:Android平台VLC媒体播放器探索之路系列】之一:VLC播放器开篇
作者:郭嘉 邮箱:allenwells@163.com 博客:http://blog.csdn.net/allenwells github:https://github.com/AllenWells ...
- VLC媒体播放器Web插件详细说明
原文地址:https://wiki.videolan.org/Documentation:WebPlugin/ 简介:使用视频构建网页 该VLC媒体播放器 webplugins是原生浏览器插件,类似于 ...
- 如何更新VLC媒体播放器
The VideoLAN project releases regular updates for the VLC Media Player. These updates add new featur ...
- linux自带视频播放VLC,如何将VLC媒体播放器设置为默认视频播放器?
问题描述 我似乎无法将VLC媒体播放器设置为默认视频播放器.我已进入系统设置→系统信息→默认应用程序,并将"Video"更改为VLC媒体播放器. 但是,默认情况下,所有电影仍然使用 ...
- VLC媒体播放器系统结构
http://blog.csdn.net/buffi/article/details/7174421 VLC媒体播放器系统结构 VLC是免费和 开源跨平台多媒体播放器,一个可以播放大部分多媒体格式如D ...
- VLC 媒体播放器 libmicrodns 库修复 RCE 漏洞
聚焦源代码安全,网罗国内外最新资讯! 编译:奇安信代码卫士团队 思科 Talos 安全研究员警告称,Videolabs 最近修复了 libmicrodns 库中的多个漏洞,它们可导致拒绝服务和任意代 ...
- 在openSUSE-Leap-15.2-DVD-x86_64下使用VLC媒体播放器
在openSUSE-Leap-15.2-DVD-x86_64下使用VLC媒体播放器 原文连接:http://blog.sina.com.cn/s/blog_76edd3f90102z51v.html ...
- 使VLC媒体播放器看起来很棒的10大皮肤
VLC media player is terrific for playing all kinds of media files on your system but you may not car ...
- kali2020 vnc安装,在Kali Linux 2020.x上安装和卸载VLC媒体播放器的方法
本文介绍在Kali Linux 2020.x系统上安装和卸载VLC media Player(VLC媒体播放器)的方法.大多数Linux发行版在其上游存储库中包含VLC软件包,要在Kali Linux ...
最新文章
- JSP内置对象-page
- makefile小技巧
- android webview 自定义404错误页面!
- 安卓开发入门到精通!免费Android高级工程师学习资源,系列篇
- messagedigest 图片加密_MessageDigest 加密和解密2
- [C语言] 插入排序之直接插入排序的特性及实现
- android 录音原始文件_Android 11可能最终会取消Android对视频录制的4GB文件大小限制...
- VScode快捷键(持续更新)
- Https网络安全传输详解
- 如何在word(非wps)里面插入公式和编号(完美格式)
- 台达内部速度指令_台达PLC连续脉冲输出如何控制速度
- 网络恶趣实验——二层广播风暴
- OPENCV提取图片中的文字
- android 系统提醒功能,Android 向系统日历中添加提醒(踩坑)
- java杨戬的角色_非人哉:游戏角色反映了神仙们的爱好,杨戬太让人意外了
- 微信小程序本地缓存在哪里?
- PHP error_reporting
- 持久层的EAO颗粒封装
- 计算机自动更新的作用,电脑自动更新系统的好处和坏处有哪些?
- python集合中的元素不允许重复_Python语言中同一个集合中的元素不会重复,每个元素都是唯一的。-智慧树Python数据分析与数据可视化章节答案...