1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Chromecast</title>
<link rel="icon" type="image/png" href="./images/favicon.png">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<button is="google-cast-button"></button>
<script>
/* Initialisation de l'API */
initializeCastApi = function() {
cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID, /* A remplacer par l'id de l'application */
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
});
};
/* Récupère la session courante */
var castSession = cast.framework.CastContext.getInstance().getCurrentSession();
/* Charge le media */
var currentMediaURL = 'http://commondatastorage.googleapis.com/gtv-videos-bucket/big_buck_bunny_1080p.mp4';
var contentType = 'video/mp4';
var mediaInfo = new chrome.cast.media.MediaInfo(currentMediaURL, contentType);
var request = new chrome.cast.media.LoadRequest(mediaInfo);
castSession.loadMedia(request).then(
function() {
console.log('Load succeed');
},
function(errorCode) {
console.log('Error code: ' + errorCode);
}
);
/* Variables de lecture */
var player = new cast.framework.RemotePlayer();
var playerController = new cast.framework.RemotePlayerController(player);
</script>
<script>
initializeCastApi = function() {
cast.framework.CastContext.getInstance().setOptions({
receiverApplicationId: applicationId,
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
});
};
</script>
<script type="text/javascript" src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
</body>
</html> |