Remove the ghetto REST flash-based video player

master
jvoisin 6 years ago
parent 643be3930f
commit 70bc0f6c04
  1. 34
      airsonic-main/src/main/java/org/airsonic/player/controller/SubsonicRESTController.java
  2. 2
      airsonic-main/src/main/java/org/airsonic/player/security/GlobalSecurityConfig.java
  3. 141
      airsonic-main/src/main/webapp/WEB-INF/jsp/rest/videoPlayer.jsp
  4. 6
      airsonic-main/src/main/webapp/crossdomain.xml
  5. BIN
      airsonic-main/src/main/webapp/flash/jw-player-5.10.swf
  6. BIN
      airsonic-main/src/main/webapp/flash/jw-player-libresonic-skin.zip
  7. BIN
      airsonic-main/src/main/webapp/flash/whotube.zip
  8. 1
      airsonic-main/src/main/webapp/script/jwplayer-5.10.min.js
  9. 4320
      airsonic-main/src/main/webapp/script/prototype.js
  10. 4
      airsonic-main/src/main/webapp/script/swfobject.js

@ -1938,40 +1938,6 @@ public class SubsonicRESTController {
return result; return result;
} }
@SuppressWarnings("UnusedParameters")
public ModelAndView videoPlayer(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request);
Map<String, Object> map = new HashMap<String, Object>();
int id = getRequiredIntParameter(request, "id");
MediaFile file = mediaFileService.getMediaFile(id);
int timeOffset = getIntParameter(request, "timeOffset", 0);
timeOffset = Math.max(0, timeOffset);
Integer duration = file.getDurationSeconds();
if (duration != null) {
map.put("skipOffsets", VideoPlayerController.createSkipOffsets(duration));
timeOffset = Math.min(duration, timeOffset);
duration -= timeOffset;
}
map.put("id", request.getParameter("id"));
map.put("u", request.getParameter("u"));
map.put("p", request.getParameter("p"));
map.put("c", request.getParameter("c"));
map.put("v", request.getParameter("v"));
map.put("video", file);
map.put("maxBitRate", getIntParameter(request, "maxBitRate", VideoPlayerController.DEFAULT_BIT_RATE));
map.put("duration", duration);
map.put("timeOffset", timeOffset);
map.put("bitRates", VideoPlayerController.BIT_RATES);
map.put("autoplay", getBooleanParameter(request, "autoplay", true));
ModelAndView result = new ModelAndView("rest/videoPlayer");
result.addObject("model", map);
return result;
}
@RequestMapping(value = "/getCoverArt") @RequestMapping(value = "/getCoverArt")
public void getCoverArt(HttpServletRequest request, HttpServletResponse response) throws Exception { public void getCoverArt(HttpServletRequest request, HttpServletResponse response) throws Exception {
request = wrapRequest(request); request = wrapRequest(request);

@ -162,7 +162,7 @@ public class GlobalSecurityConfig extends GlobalAuthenticationConfigurerAdapter
.and().authorizeRequests() .and().authorizeRequests()
.antMatchers("/recover*", "/accessDenied*", .antMatchers("/recover*", "/accessDenied*",
"/style/**", "/icons/**", "/flash/**", "/script/**", "/style/**", "/icons/**", "/flash/**", "/script/**",
"/sonos/**", "/crossdomain.xml", "/login", "/error") "/sonos/**", "/login", "/error")
.permitAll() .permitAll()
.antMatchers("/personalSettings*", "/passwordSettings*", .antMatchers("/personalSettings*", "/passwordSettings*",
"/playerSettings*", "/shareSettings*", "/passwordSettings*") "/playerSettings*", "/shareSettings*", "/passwordSettings*")

@ -1,141 +0,0 @@
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1" %>
<html>
<head>
<%@ include file="../include.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../<spring:theme code="styleSheet"/>" type="text/css">
<c:url value="/rest/stream.view" var="streamUrl">
<c:param name="c" value="${model.c}"/>
<c:param name="v" value="${model.v}"/>
<c:param name="id" value="${model.id}"/>
</c:url>
<script type="text/javascript" src="<c:url value="/script/swfobject.js"/>"></script>
<script type="text/javascript" src="<c:url value="/script/prototype.js"/>"></script>
<script type="text/javascript" language="javascript">
var player;
var position;
var maxBitRate = ${model.maxBitRate};
var timeOffset = ${model.timeOffset};
function init() {
var flashvars = {
id:"player1",
skin:"<c:url value="/flash/whotube.zip"/>",
screencolor:"000000",
autostart:false,
bufferlength:4,
backcolor:"<spring:theme code="backgroundColor"/>",
frontcolor:"<spring:theme code="textColor"/>",
provider:"video"
};
var params = {
allowfullscreen:"true",
allowscriptaccess:"always"
};
var attributes = {
id:"player1",
name:"player1"
};
swfobject.embedSWF("<c:url value="/flash/jw-player-5.10.swf"/>", "placeholder1", "360", "240", "9.0.0", false, flashvars, params, attributes);
}
function playerReady(thePlayer) {
player = $("player1");
player.addModelListener("TIME", "timeListener");
<c:if test="${model.autoplay}">
play();
</c:if>
}
function play() {
var list = new Array();
list[0] = {
file:"${streamUrl}&maxBitRate=" + maxBitRate + "&timeOffset=" + timeOffset + "&p=${model.p}" + "&u=${model.u}",
duration:${model.duration} - timeOffset,
provider:"video"
};
player.sendEvent("LOAD", list);
player.sendEvent("PLAY");
}
function timeListener(obj) {
var newPosition = Math.round(obj.position);
if (newPosition != position) {
position = newPosition;
updatePosition();
}
}
function updatePosition() {
var pos = parseInt(timeOffset) + parseInt(position);
var minutes = Math.round(pos / 60);
var seconds = pos % 60;
var result = minutes + ":";
if (seconds < 10) {
result += "0";
}
result += seconds;
$("position").innerHTML = result;
}
function changeTimeOffset() {
timeOffset = $("timeOffset").getValue();
play();
}
function changeBitRate() {
maxBitRate = $("maxBitRate").getValue();
timeOffset = parseInt(timeOffset) + parseInt(position);
play();
}
</script>
</head>
<body class="mainframe bgcolor1" onload="init();">
<h1>${model.video.title}</h1>
<div id="wrapper" style="padding-top:1em">
<div id="placeholder1"><span class="warning"><a href="http://www.adobe.com/go/getflashplayer"><fmt:message key="playlist.getflash"/></a></span></div>
</div>
<div style="padding-top:1.3em;padding-bottom:0.7em;font-size:16px">
<span id="progress" style="padding-right:0.5em">0:00</span>
<select id="timeOffset" onchange="changeTimeOffset();" style="padding-left:0.25em;padding-right:0.25em;margin-right:0.5em;font-size:16px">
<c:forEach items="${model.skipOffsets}" var="skipOffset">
<c:choose>
<c:when test="${skipOffset.value eq model.timeOffset}">
<option selected="selected" value="${skipOffset.value}">${skipOffset.key}</option>
</c:when>
<c:otherwise>
<option value="${skipOffset.value}">${skipOffset.key}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
<select id="maxBitRate" onchange="changeBitRate();" style="padding-left:0.25em;padding-right:0.25em;margin-right:0.5em;font-size:16px">
<c:forEach items="${model.bitRates}" var="bitRate">
<c:choose>
<c:when test="${bitRate eq model.maxBitRate}">
<option selected="selected" value="${bitRate}">${bitRate} Kbps</option>
</c:when>
<c:otherwise>
<option value="${bitRate}">${bitRate} Kbps</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
</div>
</body>
</html>

@ -1,6 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save