Closed samueleastdev closed 3 years ago
Just wanted to follow up I have built a very simple app to test sending customData and it sends without any issues see below.
<!DOCTYPE html>
<html data-cast-api-enabled="true">
<head>
<title>Test App</title>
<script src="//www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<form>
<button type="button" id="castme">Click To Cast</button>
<button type="button" id="stop">Click To Stop</button>
</form>
<script>
var session = null;
function sessionListener(e) {
session = e;
console.log('New session');
if (session.media.length != 0) {
console.log('Found ' + session.media.length + ' sessions.');
}
}
function receiverListener(e) {
if( e === 'available' ) {
console.log("Chromecast was found on the network.");
}
else {
console.log("There are no Chromecasts available.");
}
}
function onInitSuccess() {
console.log("Initialization succeeded");
}
function onInitError() {
console.log("Initialization failed");
}
function initializeCastApi() {
var applicationID = chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID;
var sessionRequest = new chrome.cast.SessionRequest('0000000');
var apiConfig = new chrome.cast.ApiConfig(sessionRequest,
sessionListener,
receiverListener);
chrome.cast.initialize(apiConfig, onInitSuccess, onInitError);
};
// Start
function loadMedia() {
if (!session) {
console.log("No session.");
return;
}
var mediaInfo = new chrome.cast.media.MediaInfo('https://00000000000.cloudfront.net/00000000000/master.mpd');
mediaInfo.contentType = 'application/dash+xml';
mediaInfo.customData = {
'licenseUrl': 'https://widevine.com/server-url'
};
var request = new chrome.cast.media.LoadRequest(mediaInfo);
request.autoplay = true;
session.loadMedia(request, onLoadSuccess, onLoadError);
}
function onLoadSuccess() {
console.log('Successfully loaded video.');
}
function onLoadError(e) {
console.log('Failed.', e);
}
function onRequestSessionSuccess(e) {
console.log("Successfully created session: " + e.sessionId);
session = e;
loadMedia();
}
function onLaunchError() {
console.log("Error connecting to the Chromecast.");
}
function launchApp() {
console.log("Launching the Chromecast App...");
chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError);
}
// Stop
function stopApp() {
session.stop(onStopAppSuccess, onStopAppError);
}
function onStopAppSuccess() {
console.log('Successfully stopped app.');
}
function onStopAppError() {
console.log('Error stopping app.');
}
$( document ).ready(function(){
var loadCastInterval = setInterval(function(){
if (chrome.cast.isAvailable) {
clearInterval(loadCastInterval);
initializeCastApi();
} else {
console.log('Unavailable');
}
}, 1000);
$('#castme').click(function(){
launchApp();
});
$('#stop').click(function(){
stopApp();
});
});
</script>
</body>
</html>
Found the issue you should probably update the docs.
This
chromecast: {
requestTitleFn: function(source) { // Not required
return titles[source.url];
},
requestSubtitleFn: function(source) { // Not required
return subtitles[source.url];
},
requestCustomDataFn: function(source) { // Not required
return customData[source.url];
}
},
Needs to be this.
chromecast: {
requestTitleFn: function(source) { // Not required
return titles[source.src];
},
requestSubtitleFn: function(source) { // Not required
return subtitles[source.src];
},
requestCustomDataFn: function(source) { // Not required
return customData[source.src];
}
},
Thanks ;)
I have a custom receiver setup with the following code.
I am using the plugin customData to try and send data to the receiver like below.
I am debugging and I am not getting any customData sent below is the console log from the custom receiver loadRequest.