nativescript - 如何在 nativescript-exoplayer 中捕获 PlayerError 并显示适当的警报
问题描述
当用户有连接问题时,我在控制台中得到这个:
PlayerError com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.upstream.HttpDataSource$HttpDataSourceException: Unable to connect to ...
我想知道是否有可能捕捉到这个错误并告诉用户他们有连接问题并且视频无法加载。我在 nativescript-vue 中使用这个很棒的插件
这是我在 nativescript-vue 应用程序中使用该组件的方式:
<exoplayer
:src="video.src"
autoplay="true"
controls="false"
height="300"
@finished="done"
/>
解决方案
我在 node_modules 插件的 videoplayer.android.js 文件中找到了这个:
onPlayerError: function (error) {
},
所以我给组件中的全局对象分配了一个回调函数,并在 onPlayerError 函数中调用了全局对象上的函数。
现在适用于安卓。
推荐阅读
- javascript - JavaScript 音频自动播放为什么不能在新版本的 chrome 上工作?
- html - 如何创建内部有圆圈的曲线?
- sql - 我创建了一个过程并在此之后键入,我只是修改了过程光标中的一列并键入
- c - what does enum DescriptorType DescriptorType :8; mean in C code?
- c++ - PCL 安装教程
- ios - 无法访问 Swift 文件中的 Bundle
- python - 无法使用 pip 安装聊天机器人
- javascript - 为什么即使我已经发送了响应,我的“then”承诺链接仍然执行?
- pyspark - 如何在更短的时间内向初始 DataFrame 添加大量列(5000~1000 列)?
- spring - Webflux WebClient中如何自定义异常?