silvermine chromecast
This commit is contained in:
parent
6d5baafecc
commit
16dea6cbc4
@ -2,7 +2,8 @@
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ videojs_version }}/video-js.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/{{ videojs_version }}/video.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/castjs/{{ castjs_version }}/cast.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@silvermine/videojs-chromecast@latest/dist/silvermine-videojs-chromecast.min.js"></script>
|
||||
<script src="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1"></script>
|
||||
<script src="{{ script }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
12
script.js
12
script.js
@ -5,25 +5,19 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
let bodies = document.getElementsByTagName("body");
|
||||
if(bodies.length === 1) {
|
||||
let body = bodies[0];
|
||||
let cast = document.createElement("button");
|
||||
cast.innerHtml = "Google Cast";
|
||||
let cjs = new Castjs();
|
||||
cast.addEventListener("click", () => {
|
||||
if(cjs.available) {
|
||||
cjs.cast(upstream);
|
||||
}
|
||||
});
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.addEventListener("load", () => {
|
||||
let video = document.createElement("video");
|
||||
video.className = "video-js";
|
||||
body.appendChild(video);
|
||||
body.appendChild(cast);
|
||||
let ctype = xhr.getResponseHeader("Content-Type");
|
||||
console.log(ctype);
|
||||
let options = {};
|
||||
options.controls = true;
|
||||
options.liveui = true;
|
||||
options.techOrder = ["chromecast", "html5"];
|
||||
options.plugins = {};
|
||||
options.plugins.chromecast = {};
|
||||
let player = videojs(video, options);
|
||||
let source = {};
|
||||
source.type = ctype;
|
||||
|
Loading…
Reference in New Issue
Block a user