【问题标题】:How to catch PlayerError in nativescript-exoplayer and show a propper alert如何在 nativescript-exoplayer 中捕获 PlayerError 并显示适当的警报
【发布时间】:2020-04-28 01:56:23
【问题描述】:

当用户遇到连接问题时,我会在控制台中看到:

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"
  />

【问题讨论】:

  • 插件没有实现,你可以从error callback获取一个fork并触发一个事件。
  • @Manoj 你真的是社区最大的希望:)) 非常感谢!

标签: nativescript nativescript-vue


【解决方案1】:

我在 node_modules 插件的 videoplayer.android.js 文件中找到了这个:

onPlayerError: function (error) {

},

所以我为组件中的全局对象分配了一个回调函数,并在 onPlayerError 函数中对全局对象调用了该函数。
现在适用于安卓系统。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-12
    • 2011-10-22
    • 2023-03-25
    • 2019-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多