【问题标题】:How to include JW Player in Nativescript with Angular?如何在带有 Angular 的 Nativescript 中包含 JW Player?
【发布时间】:2020-12-17 08:04:19
【问题描述】:

我正在使用带有 Angular 的 NativeScript。我想在应用程序中添加 JW Player 来为我的应用程序播放视频,但我无法弄清楚。我的代码如下:-

home.html

<GridLayout row="0" #jwVideoPlayer>               
</GridLayout> 

home.ts

import { Component, OnInit, ViewChild, ElementRef } from "@angular/core";
declare var jwplayer: any;

@Component({ 
    selector: "home", 
    templateUrl: "./home.component.html",    
})

export class HomeComponent implements OnInit {
   @ViewChild('jwVideoPlayer', { static: false }) jwVideoPlayer: ElementRef;

   ngOnInit() {
     const playerJw = jwplayer('jwVideoPlayer').setup({
            title: 'Player Test',
            playlist: 'https://cdn.jwplayer.com/v2/media/8L4m9FJB',
            width: 640,
            height: 360,
            aspectratio: '16:9',
            mute: false,
            autostart: true,
            primary: 'html5',
        });
   }
}

由于我无法弄清楚在 NativeScript 中包含 JW Player 的方法,我遇到了以下错误:-

错误参考错误:找不到变量:jwplayer

在 web 项目中,我通常使用下面一行来包含 JW Player。

<script type="text/javascript">jwplayer.key="1D+blahblah/blahblah=="</script>

Nativescript 支持 JW Player 吗?

谁能帮助我了解如何在 NativeScript 应用程序中包含 JW Player?

【问题讨论】:

    标签: html5-video nativescript jwplayer nativescript-angular


    【解决方案1】:

    您可以通过以下命令使用 nativescript-jwplayer-web 插件

    npm i nativescript-jwplayer-web --save
    

    【讨论】:

      猜你喜欢
      • 2018-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-22
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 2019-12-05
      相关资源
      最近更新 更多