rdkcentral / Lightning-SDK

SDK for Lightning framework
Apache License 2.0
130 stars 69 forks source link

Dash support for mediaplayer #80

Closed KadeejaBai closed 4 years ago

KadeejaBai commented 4 years ago

I'm looking for dash support for mediaplayer. Is it possible to use dash.js with a mediaplayer?

erikhaandrikman commented 4 years ago

Yeah it's possible, you just need to include dashjs to your project and initialize it and attach the videotag;

import {Lightning, MediaPlayer} from 'wpe-lightning-sdk';

export default class Player extends Lightning.Component {
   static _template(){
    return {
     MediaPlayer:{  type: MediaPlayer },
     Controls: { ... }
    }
  }

 _init(){
    // get ref to video-tag
    cont video = this.tag("MediaPlayer").videoEl;
    // create new context
    this.dash = dashjs.MediaPlayer().create();
    this.dash.initialize();
    // attach video reference
    this.dash.attachView(video); 
  } 

  play(manifest, drm){
    // hand over license
    this.dash.setProtectionData(drm);
    // set manifest
    this.dash.attachSource(manifest);
  }

}
KadeejaBai commented 4 years ago

I'm facing an error while importing dashjs. Am i doing anything wrong? image

import {Lightning, MediaPlayer} from 'wpe-lightning-sdk';
import dashjs from 'dashjs';
export default class Player extends Lightning.Component {
   static _template(){
    return {
     MediaPlayer:{  type: MediaPlayer },
     Controls: { ... }
    }
  }

 _init(){
    // get ref to video-tag
    cont video = this.tag("MediaPlayer").videoEl;
    // create new context
    this.dash = dashjs.MediaPlayer().create();
    this.dash.initialize();
    // attach video reference
    this.dash.attachView(video); 
  } 

  play(manifest, drm){
    // hand over license
    this.dash.setProtectionData(drm);
    // set manifest
    this.dash.attachSource(manifest);
  }
erikhaandrikman commented 4 years ago

Is it possible to share an example that we can run and debug?

KadeejaBai commented 4 years ago

I believe this error is due to the dashjs import. The code updated with the comment. This is the version of dashjs that I'm using. "dashjs": "^3.1.1"

KadeejaBai commented 4 years ago

Fixed :) this was the import import 'dashjs/dist/dash.all.min'

krishdarling143 commented 4 years ago

Here video is not displaying but audio is comming

import {Lightning, MediaPlayer} from 'wpe-lightning-sdk'; import 'dashjs/dist/dash.all.debug'

export default class DRM extends Lightning.Component { static _template(){ return { MediaPlayer:{ type: MediaPlayer },

}

}

_init(){ console.log(dashjs) const video = this.tag("MediaPlayer").videoEl;
this.dash = dashjs.MediaPlayer().create();
this.dash.initialize(); console.log(this.dash) this.dash.attachView(video);

} _handleEnter(){ this.dash.attachSource('https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd');

} } what will be the reason please help me