如何将jwplayer v7与Ionic2集成

时间:2017-02-22 21:56:42

标签: ionic2

我正在尝试将jwplayer 7.9.2与一个空白的Ionic2项目集成,但我无法使其正常工作,我有一条错误消息:

  

缺少许可证密钥

基本上,在我的组件中,我输入以下代码:

关于组件页面:

import { Component, AfterViewInit } from '@angular/core';    
import { NavController } from 'ionic-angular';
import * as jwplayer from 'jwplayer';

jwplayer.key = "<my_key>";


@Component({
  selector: 'page-about',
  templateUrl: 'about.html'
})
export class AboutPage implements AfterViewInit {

  ngAfterViewInit(): void {

     var playerInstance = jwplayer("video");

     var options = {
       "playlist": [
         {
           "sources": [
             {
               "default": false,
               "file": "https://wowza.jwplayer.com/live/jelly.stream/playlist.m3u8",                   
               "type": "hls",
               "label": "0",
               "preload": "none"
             }
           ]
         }
       ],
       primary: "html5",
       hlshtml: true,
       height: 500,
       width: '100%'
     }

     playerInstance.setup(options);

     playerInstance.on('ready', function () {
       console.log('Player Ready');
       playerInstance.play();
     })
  }
}

About.html

<ion-header>
  <ion-navbar>
    <ion-title>
      About
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <div id="video"></div>    
</ion-content>

1 个答案:

答案 0 :(得分:0)

您需要tro创建一个帐户然后获取许可证密钥。