From b8ade50810f87e46f5ee09b53f9622fbc5f282cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Thu, 22 Dec 2016 21:58:46 +0100 Subject: [PATCH] Controller migration --- .../player/controller/M3UController.java | 40 +++++++++---------- .../src/main/resources/libresonic-servlet.xml | 6 --- 2 files changed, 18 insertions(+), 28 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/controller/M3UController.java b/libresonic-main/src/main/java/org/libresonic/player/controller/M3UController.java index e04cd4ad..b11cc354 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/controller/M3UController.java +++ b/libresonic-main/src/main/java/org/libresonic/player/controller/M3UController.java @@ -19,16 +19,6 @@ */ package org.libresonic.player.controller; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.springframework.web.servlet.ModelAndView; -import org.springframework.web.servlet.mvc.Controller; - import org.libresonic.player.domain.MediaFile; import org.libresonic.player.domain.PlayQueue; import org.libresonic.player.domain.Player; @@ -36,18 +26,35 @@ import org.libresonic.player.service.PlayerService; import org.libresonic.player.service.SettingsService; import org.libresonic.player.service.TranscodingService; import org.libresonic.player.util.StringUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +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.io.IOException; +import java.io.PrintWriter; +import java.util.List; /** * Controller which produces the M3U playlist. * * @author Sindre Mehus */ -public class M3UController implements Controller { +@Controller +@RequestMapping("/play.m3u") +public class M3UController { + @Autowired private PlayerService playerService; + @Autowired private SettingsService settingsService; + @Autowired private TranscodingService transcodingService; + @RequestMapping(method = RequestMethod.GET) public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setContentType("audio/x-mpegurl"); response.setCharacterEncoding(StringUtil.ENCODING_UTF8); @@ -115,15 +122,4 @@ public class M3UController implements Controller { return playQueue.isEmpty() ? null : transcodingService.getSuffix(player, playQueue.getFile(0), null); } - public void setPlayerService(PlayerService playerService) { - this.playerService = playerService; - } - - public void setSettingsService(SettingsService settingsService) { - this.settingsService = settingsService; - } - - public void setTranscodingService(TranscodingService transcodingService) { - this.transcodingService = transcodingService; - } } diff --git a/libresonic-main/src/main/resources/libresonic-servlet.xml b/libresonic-main/src/main/resources/libresonic-servlet.xml index e2cafc86..6a9618fb 100644 --- a/libresonic-main/src/main/resources/libresonic-servlet.xml +++ b/libresonic-main/src/main/resources/libresonic-servlet.xml @@ -15,11 +15,6 @@ - - - - - @@ -126,7 +121,6 @@ downloadController wapController restController - m3uController streamController hlsController externalPlayerController