0
votes

I'm trying to stream Widevine DRM content from an Android app to Chromecast with custom receiver (CAF), but I don't know how to dynamically set the license url.

In the receiver example below the license is hardcoded, but I need to send it as a parameter from the sender app to the receiver app.

<html>
<head>
  <script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js">
  </script>
</head>
<body>
  <cast-media-player></cast-media-player>
  <script>
    //cast.framework.CastReceiverContext.getInstance().start();

    const context = cast.framework.CastReceiverContext.getInstance();
    const playbackConfig = new cast.framework.PlaybackConfig();
    //Widevine license URL
    playbackConfig.licenseUrl = 'http://10.4.251.23:8094/license';
    context.start({playbackConfig: playbackConfig});

  </script>
</body>
</html>

Here's the sender app (Android):

String mStreamUrl = getStreamUrl();
String licenseUrl = getLicenseUrl();

MediaMetadata movieMetadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE);

movieMetadata.putString(MediaMetadata.KEY_TITLE, childTitle.getName());
movieMetadata.addImage(new WebImage(Uri.parse(childTitle.getBackgrounImage())));

return new MediaInfo.Builder(mStreamUrl)
        .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
        .setContentType("video/mp4")
        .setMetadata(movieMetadata)
        .build();

}

1

1 Answers

0
votes

The MediaInfo.Builder allows you send custom data in JSON format also using this method

public MediaInfo.Builder setCustomData (JSONObject customData)