matvp91 / shaka-player-react

A simple React component wrapper for shaka-player
MIT License
108 stars 34 forks source link

DRM content #33

Open TDUser91 opened 1 year ago

TDUser91 commented 1 year ago

how do I play drm streaming content using this library ? Thank you

example dataSource:

url : https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd
license: https://cwip-shaka-proxy.appspot.com/no_auth
pluvd7j commented 6 months ago

@TDUser91 you can go with this way

import React, { useRef, useEffect } from 'react'
import ShakaPlayer from 'shaka-player-react'
import 'shaka-player/dist/controls.css'

const Player = () => {
const shakaRef = useRef(null)
const drmLicenseUrl = 'https://cwip-shaka-proxy.appspot.com/no_auth'
const { player, ui, videoElement } = shakaRef?.current

useEffect(()=>{
if (drmLicenseUrl !== '') {
          player?.configure({
            drm: {
              servers: {
                'com.widevine.alpha': drmLicenseUrl,
              },
            },
            })
            }
},[)

return(
 <ShakaPlayer
        autoPlay
        ref={shakaRef}
        src={'https://storage.googleapis.com/shaka-demo-assets/angel-one-widevine/dash.mpd'}
      />)
            }
    export default Player;