如何在 nativescript-exoplayer 中捕获 PlayerError 并显示正确的警报
How to catch PlayerError in nativescript-exoplayer and show a propper alert
当用户遇到连接问题时,我会在控制台中看到:
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 函数中调用了全局对象上的函数。
现在为 android 工作。
当用户遇到连接问题时,我会在控制台中看到:
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 函数中调用了全局对象上的函数。
现在为 android 工作。