Controller migration

master
Rémi Cocula 8 years ago
parent 24996c628e
commit b2d58fee47
  1. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/HLSController.java
  2. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/VideoPlayerController.java
  3. 8
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -50,7 +50,7 @@ import org.libresonic.player.util.StringUtil;
*
* @author Sindre Mehus
*/
@Controller
@Controller(value = "hlsController")
@RequestMapping("/hls/**")
public class HLSController {

@ -19,17 +19,6 @@
*/
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.User;
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.SettingsService;
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.
*
* @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[] BIT_RATES = {200, 300, 400, 500, 700, 1000, 1200, 1500, 2000, 3000, 5000};
@Autowired
private MediaFileService mediaFileService;
@Autowired
private SettingsService settingsService;
@Autowired
private PlayerService playerService;
@Autowired
private SecurityService securityService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
User user = securityService.getCurrentUser(request);
@ -87,9 +94,7 @@ public class VideoPlayerController extends ParameterizableViewController {
map.put("defaultBitRate", DEFAULT_BIT_RATE);
map.put("user", user);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
return new ModelAndView("videoPlayer", "model", map);
}
public static Map<String, Integer> createSkipOffsets(int durationSeconds) {
@ -100,19 +105,4 @@ public class VideoPlayerController extends ParameterizableViewController {
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.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">
<property name="viewName" value="externalPlayer"/>
<property name="mediaFileService" ref="mediaFileService"/>
@ -81,7 +74,6 @@
<property name="alwaysUseFullPath" value="true"/>
<property name="mappings">
<props>
<prop key="/videoPlayer.view">videoPlayerController</prop>
<prop key="/db.view">dbController</prop>
<prop key="/podcast/**">podcastController</prop>
<prop key="/wap/download.view">downloadController</prop>

Loading…
Cancel
Save