【问题标题】:access exoplayer element in component in Nativescript angular访问 Nativescript angular 组件中的 exoplayer 元素
【发布时间】:2018-08-13 16:01:59
【问题描述】:

我正在使用 Nativescript 并使用 exoplayer 组件,我找不到任何如何在组件中访问它,例如我想更改同一页面中的 src(例如我们有不同的质量我们想要更改 src,我们应该销毁播放器并用新的 src 重新初始化它),获取一些事件,如播放、错误和......也许还有我的自定义操作按钮

我也试过这个:

@ViewChild(Video)
private player: Video;

但它是未定义的

这是我的视图代码:

<StackLayout orientation="vertical" width="100%" height="100%" backgroundColor="black">
    <exoplayer *ngIf="is_loaded" id="player"
               [src]="episode.link
               playbackReady="change_player_quality"
               autoplay="true"
               height="300"
               class="exoplayer"></exoplayer>
</StackLayout>

【问题讨论】:

    标签: angular nativescript exoplayer


    【解决方案1】:

    我自己找到了结果,所以我告诉你发生了什么, 我把视图子变成了这样:

    @ViewChild('player') player: ElementRef;
    

    并且我在播放器中添加了一个标签:

    <exoplayer id="player" [src]="video.link" autoplay="true" height="300" class="exoplayer" #player></exoplayer>
    

    然后当我想使用播放器 API 或更改 src 我得到这样的对象:

    this.player.nativeElement.src = 'file.mp4';
    

    或销毁:

    this.player.nativeElement.destroy();
    

    希望对你有帮助

    祝你好运

    【讨论】:

      猜你喜欢
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多