Implementing Shaka Player with Fairplay with Azure DRM service

536 Views Asked by At

I have initialise shaka player with all necessary DRM configuration of fairplay. But I am not unable to load audio. I was to able integrate widevine and able to play it. No error is been shown and need to know what is the issue. Can anyone help to debug the issue. We are using Azure DRM services to convert the assets and generating the url. I am able to play URL in azure media player but not able able to play in shaka - player

    shaka.polyfill.installAll();
    if (shaka.Player.isBrowserSupported()) {
      this.videoElement = this.videoElementRef?.nativeElement;
      this.videoContainerElement = this.videoContainerRef?.nativeElement;
      this.initPlayer();
    } else {
      console.error('Browser not supported!');
    }

 this.player = new shaka.Player(this.videoElement);
    console.log(this.player)
   
    // this.player.configure({
   //       drm: {
   //         servers: {
   //         //  'com.widevine.alpha': '',
   //           'com.apple.fps.1_0':''
   //         },
   //       },
   //    });


   this.player.getNetworkingEngine().registerRequestFilter( (type:any, request:any) => {
 
     console.log("registerRequestFilter called") 

         if (type == shaka.net.NetworkingEngine.RequestType.LICENSE) {
           request.headers['authorization'] = "";
           request.url = this.serverProcessSPCPath
           console.log("getting license")       
      }
    });   

    
    try {
     const req = await fetch('URL');
     this.hlsCertificate = await req.arrayBuffer();
     console.log(this.hlsCertificate)
   
   } catch (error) {
     console.log('ERROR', 'Load FairPlay Certificate Error: ' + error)
    
   }
   
   this.player.configure('drm.initDataTransform', (initData:any,content:any,third:any) => {
   
    //const processedData = String.fromCharCode.apply(null, (new Uint16Array(d)) as ArrayBuffer) .substring(1);
    const processedData = String.fromCharCode.apply(null,Array.from<number>(new Uint8Array(initData.buffer))) ;
    const contentId = new URL(processedData.substring(1)).hostname;
    const cert = this.player.drmInfo().serverCertificate;
    this.serverProcessSPCPath = processedData.substring(1).replace('skd://', 'https://');
    return shaka.util.FairPlayUtils.initDataTransform(initData, contentId, cert);
});

  

this.player.configure('drm.advanced.com\\.apple\\.fps\\.1_0.serverCertificate',  new Uint8Array(this.hlsCertificate));
   
   let videoUrl = "URL";
   console.log(this.videoElement?.duration)
   console.log(this.player.getConfiguration()) 

   this.player.addEventListener('error', this.ErrHandler.bind(this))
   
   this.player.load(videoUrl).then(() => {
    
  }).catch((error: any) => {
    console.log('ERROR', 'Load Manifest Error: ' + error)
  
  })

enter image description here

0

There are 0 best solutions below