Fix the video player that was broken in cf1f86f

master
jvoisin 6 years ago
parent e13877203b
commit 40f7c73390
  1. 12
      airsonic-main/src/main/webapp/WEB-INF/jsp/videoPlayer.jsp
  2. 22
      airsonic-main/src/main/webapp/script/videoPlayerCast.js

@ -8,7 +8,6 @@
<script type="text/javascript" src="<c:url value="/dwr/engine.js"/>"></script> <script type="text/javascript" src="<c:url value="/dwr/engine.js"/>"></script>
<script type="text/javascript" src="<c:url value="/dwr/interface/starService.js"/>"></script> <script type="text/javascript" src="<c:url value="/dwr/interface/starService.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/cast_sender-v1.js"/>"></script> <script type="text/javascript" src="<c:url value="/script/cast_sender-v1.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/videoPlayerCast.js"/>"></script>
<script type="text/javascript" language="javascript"> <script type="text/javascript" language="javascript">
function toggleStar(mediaFileId, imageId) { function toggleStar(mediaFileId, imageId) {
@ -21,7 +20,18 @@
starService.star(mediaFileId); starService.star(mediaFileId);
} }
} }
var model = {
duration: ${empty model.duration ? 0: model.duration},
remoteStreamUrl: "${model.remoteStreamUrl}",
video_title: "${model.video.title}",
remoteCoverArtUrl: "${model.remoteCoverArtUrl}",
streamUrl: "${model.streamUrl}",
video_id: "${model.video.id}",
hide_share: ${model.user.shareRole ? 1: 0},
hide_download: ${model.user.downloadRole ? 1: 0}
}
</script> </script>
<script type="text/javascript" src="<c:url value="/script/videoPlayerCast.js"/>"></script>
</head> </head>
<body class="mainframe bgcolor1" style="padding-bottom:0.5em"> <body class="mainframe bgcolor1" style="padding-bottom:0.5em">

@ -77,7 +77,7 @@
this.currentMediaTime = 0; this.currentMediaTime = 0;
// @type {Number} A number for current media duration // @type {Number} A number for current media duration
this.currentMediaDuration = ${empty model.duration ? 0: model.duration}; this.currentMediaDuration = model.duration;
// @type {Boolean} A boolean to stop timer update of progress when triggered by media status event // @type {Boolean} A boolean to stop timer update of progress when triggered by media status event
this.seekInProgress = false; this.seekInProgress = false;
@ -283,7 +283,7 @@
this.currentMediaOffset = offset; this.currentMediaOffset = offset;
this.currentMediaTime = 0; this.currentMediaTime = 0;
var url = "${model.remoteStreamUrl}" + "&maxBitRate=" + this.getBitRate() + "&format=mkv&timeOffset=" + offset; var url = model.remoteStreamUrl + "&maxBitRate=" + this.getBitRate() + "&format=mkv&timeOffset=" + offset;
console.log("casting " + url); console.log("casting " + url);
var mediaInfo = new chrome.cast.media.MediaInfo(url); var mediaInfo = new chrome.cast.media.MediaInfo(url);
mediaInfo.contentType = 'video/x-matroska'; mediaInfo.contentType = 'video/x-matroska';
@ -291,8 +291,8 @@
mediaInfo.duration = this.currentMediaDuration; mediaInfo.duration = this.currentMediaDuration;
mediaInfo.metadata = new chrome.cast.media.MovieMediaMetadata(); mediaInfo.metadata = new chrome.cast.media.MovieMediaMetadata();
mediaInfo.metadata.metadataType = chrome.cast.media.MetadataType.MOVIE; mediaInfo.metadata.metadataType = chrome.cast.media.MetadataType.MOVIE;
mediaInfo.metadata.title = "${model.video.title}"; mediaInfo.metadata.title = model.video_title;
mediaInfo.metadata.images = [new chrome.cast.Image("${model.remoteCoverArtUrl}&size=384")]; mediaInfo.metadata.images = [new chrome.cast.Image(model.remoteCoverArtUrl + "&size=384")];
var request = new chrome.cast.media.LoadRequest(mediaInfo); var request = new chrome.cast.media.LoadRequest(mediaInfo);
request.autoplay = this.autoplay; request.autoplay = this.autoplay;
@ -446,7 +446,7 @@
this.currentMediaOffset = offset; this.currentMediaOffset = offset;
this.currentMediaTime = 0; this.currentMediaTime = 0;
var url = "${model.streamUrl}" + "&maxBitRate=" + this.getBitRate() + "&timeOffset=" + offset; var url = model.streamUrl + "&maxBitRate=" + this.getBitRate() + "&timeOffset=" + offset;
console.log("playing local: " + url); console.log("playing local: " + url);
this.localPlayer.src = url; this.localPlayer.src = url;
@ -491,14 +491,14 @@
* Share the video. * Share the video.
*/ */
CastPlayer.prototype.share = function () { CastPlayer.prototype.share = function () {
location.href = "createShare.view?id=${model.video.id}"; location.href = "createShare.view?id=" + model.video_id;
}; };
/** /**
* Download the video. * Download the video.
*/ */
CastPlayer.prototype.download = function () { CastPlayer.prototype.download = function () {
location.href = "download.view?id=${model.video.id}"; location.href = "download.view?id=" + model.video_id;
}; };
/** /**
@ -678,12 +678,12 @@
$("#share").on('click', this.share.bind(this)); $("#share").on('click', this.share.bind(this));
$("#download").on('click', this.download.bind(this)); $("#download").on('click', this.download.bind(this));
<c:if test="${not model.user.shareRole}"> if (model.hide_share) {
$("#share").hide(); $("#share").hide();
</c:if> }
<c:if test="${not model.user.downloadRole}"> if (model.hide_download) {
$("#download").hide(); $("#download").hide();
</c:if> }
// setInterval(this.updateDebug.bind(this), 100); // setInterval(this.updateDebug.bind(this), 100);
}; };

Loading…
Cancel
Save