Controller migration
This commit is contained in:
@@ -50,7 +50,7 @@ import org.libresonic.player.util.StringUtil;
|
|||||||
*
|
*
|
||||||
* @author Sindre Mehus
|
* @author Sindre Mehus
|
||||||
*/
|
*/
|
||||||
@Controller
|
@Controller(value = "hlsController")
|
||||||
@RequestMapping("/hls/**")
|
@RequestMapping("/hls/**")
|
||||||
public class HLSController {
|
public class HLSController {
|
||||||
|
|
||||||
|
|||||||
+21
-31
@@ -19,17 +19,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.libresonic.player.controller;
|
package org.libresonic.player.controller;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.springframework.web.bind.ServletRequestUtils;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
|
||||||
import org.springframework.web.servlet.mvc.ParameterizableViewController;
|
|
||||||
|
|
||||||
import org.libresonic.player.domain.MediaFile;
|
import org.libresonic.player.domain.MediaFile;
|
||||||
import org.libresonic.player.domain.User;
|
import org.libresonic.player.domain.User;
|
||||||
import org.libresonic.player.service.MediaFileService;
|
import org.libresonic.player.service.MediaFileService;
|
||||||
@@ -37,23 +26,41 @@ import org.libresonic.player.service.PlayerService;
|
|||||||
import org.libresonic.player.service.SecurityService;
|
import org.libresonic.player.service.SecurityService;
|
||||||
import org.libresonic.player.service.SettingsService;
|
import org.libresonic.player.service.SettingsService;
|
||||||
import org.libresonic.player.util.StringUtil;
|
import org.libresonic.player.util.StringUtil;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.ServletRequestUtils;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the page used to play videos.
|
* Controller for the page used to play videos.
|
||||||
*
|
*
|
||||||
* @author Sindre Mehus
|
* @author Sindre Mehus
|
||||||
*/
|
*/
|
||||||
public class VideoPlayerController extends ParameterizableViewController {
|
@Controller
|
||||||
|
@RequestMapping("/videoPlayer")
|
||||||
|
public class VideoPlayerController {
|
||||||
|
|
||||||
public static final int DEFAULT_BIT_RATE = 2000;
|
public static final int DEFAULT_BIT_RATE = 2000;
|
||||||
public static final int[] BIT_RATES = {200, 300, 400, 500, 700, 1000, 1200, 1500, 2000, 3000, 5000};
|
public static final int[] BIT_RATES = {200, 300, 400, 500, 700, 1000, 1200, 1500, 2000, 3000, 5000};
|
||||||
|
|
||||||
|
@Autowired
|
||||||
private MediaFileService mediaFileService;
|
private MediaFileService mediaFileService;
|
||||||
|
@Autowired
|
||||||
private SettingsService settingsService;
|
private SettingsService settingsService;
|
||||||
|
@Autowired
|
||||||
private PlayerService playerService;
|
private PlayerService playerService;
|
||||||
|
@Autowired
|
||||||
private SecurityService securityService;
|
private SecurityService securityService;
|
||||||
|
|
||||||
@Override
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
User user = securityService.getCurrentUser(request);
|
User user = securityService.getCurrentUser(request);
|
||||||
@@ -87,9 +94,7 @@ public class VideoPlayerController extends ParameterizableViewController {
|
|||||||
map.put("defaultBitRate", DEFAULT_BIT_RATE);
|
map.put("defaultBitRate", DEFAULT_BIT_RATE);
|
||||||
map.put("user", user);
|
map.put("user", user);
|
||||||
|
|
||||||
ModelAndView result = super.handleRequestInternal(request, response);
|
return new ModelAndView("videoPlayer", "model", map);
|
||||||
result.addObject("model", map);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Integer> createSkipOffsets(int durationSeconds) {
|
public static Map<String, Integer> createSkipOffsets(int durationSeconds) {
|
||||||
@@ -100,19 +105,4 @@ public class VideoPlayerController extends ParameterizableViewController {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediaFileService(MediaFileService mediaFileService) {
|
|
||||||
this.mediaFileService = mediaFileService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSettingsService(SettingsService settingsService) {
|
|
||||||
this.settingsService = settingsService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerService(PlayerService playerService) {
|
|
||||||
this.playerService = playerService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSecurityService(SecurityService securityService) {
|
|
||||||
this.securityService = securityService;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,6 @@
|
|||||||
org.libresonic.player.validator,
|
org.libresonic.player.validator,
|
||||||
org.libresonic.player.security"/>
|
org.libresonic.player.security"/>
|
||||||
|
|
||||||
<bean id="videoPlayerController" class="org.libresonic.player.controller.VideoPlayerController">
|
|
||||||
<property name="viewName" value="videoPlayer"/>
|
|
||||||
<property name="mediaFileService" ref="mediaFileService"/>
|
|
||||||
<property name="settingsService" ref="settingsService"/>
|
|
||||||
<property name="playerService" ref="playerService"/>
|
|
||||||
<property name="securityService" ref="securityService"/>
|
|
||||||
</bean>
|
|
||||||
<bean id="externalPlayerController" class="org.libresonic.player.controller.ExternalPlayerController">
|
<bean id="externalPlayerController" class="org.libresonic.player.controller.ExternalPlayerController">
|
||||||
<property name="viewName" value="externalPlayer"/>
|
<property name="viewName" value="externalPlayer"/>
|
||||||
<property name="mediaFileService" ref="mediaFileService"/>
|
<property name="mediaFileService" ref="mediaFileService"/>
|
||||||
@@ -81,7 +74,6 @@
|
|||||||
<property name="alwaysUseFullPath" value="true"/>
|
<property name="alwaysUseFullPath" value="true"/>
|
||||||
<property name="mappings">
|
<property name="mappings">
|
||||||
<props>
|
<props>
|
||||||
<prop key="/videoPlayer.view">videoPlayerController</prop>
|
|
||||||
<prop key="/db.view">dbController</prop>
|
<prop key="/db.view">dbController</prop>
|
||||||
<prop key="/podcast/**">podcastController</prop>
|
<prop key="/podcast/**">podcastController</prop>
|
||||||
<prop key="/wap/download.view">downloadController</prop>
|
<prop key="/wap/download.view">downloadController</prop>
|
||||||
|
|||||||
Reference in New Issue
Block a user