123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- /* f-video.js */
- let F_Video;
- (function () {
- F_Video = function (url, option) {
- const u = window.navigator.userAgent.toLowerCase();
- const isAndroid = u.indexOf("android") > -1;
- let player = new Object();
- let newCanvas = document.createElement("canvas");
- let params = {
- canvas: newCanvas,
- loop: option.loop || false,
- autoplay: option.autoplay || false,
- onEnded: () => {
- option.onEnded && option.onEnded();
- player.currentTime = 0;
- },
- };
- newCanvas.style.width = "100%";
- newCanvas.style.height = "100%";
- newCanvas.style.objectFit = option.objectFit || "cover";
- player = new JSMpeg.Player(url.replace(".mp4", ".ts"), {
- ...option,
- ...params,
- });
- player.domElement = newCanvas;
- // if (isAndroid) {
- // let newCanvas = document.createElement("canvas");
- // let params = {
- // canvas: newCanvas,
- // loop: option.loop || false,
- // autoplay: option.autoplay || false,
- // onEnded: () => {
- // option.onEnded && option.onEnded();
- // player.currentTime = 0;
- // },
- // };
- // newCanvas.style.width = "100%";
- // newCanvas.style.height = "100%";
- // newCanvas.style.objectFit = option.objectFit || "cover";
- // player = new JSMpeg.Player(url.replace(".mp4", ".ts"), {
- // ...option,
- // ...params,
- // });
- // player.domElement = newCanvas;
- // } else {
- // let newVideo = document.createElement("video");
- // newVideo.setAttribute("x5-video-player-type", "h5");
- // newVideo.setAttribute("x-webkit-airplay", "true");
- // newVideo.setAttribute("airplay", "allow");
- // newVideo.setAttribute("playsinline", "");
- // newVideo.setAttribute("webkit-playsinline", "");
- // newVideo.setAttribute("src", url);
- // option.loop && newVideo.setAttribute("loop", "loop");
- // !option.autoplay && newVideo.setAttribute("preload", "auto");
- // option.autoplay &&
- // window.WeixinJSBridge &&
- // window.WeixinJSBridge.invoke("getNetworkType", {}, (e) => {
- // player.play();
- // });
- // newVideo.style.width = "100%";
- // newVideo.style.height = "100%";
- // newVideo.style.objectFit = option.objectFit || "cover";
- // player = newVideo;
- // player.domElement = newVideo;
- // option.onPlay && player.addEventListener("play", option.onPlay);
- // option.onPause && player.addEventListener("pause", option.onPause);
- // option.onEnded && player.addEventListener("ended", option.onEnded);
- // }
- return player;
- };
- })();
|