Adds track controller
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package net.halfbinary.prettyplayerapi.controller
|
||||
|
||||
import com.mpatric.mp3agic.Mp3File
|
||||
import net.halfbinary.prettyplayerapi.model.TrackInfo
|
||||
import net.halfbinary.prettyplayerapi.service.MusicService
|
||||
import org.springframework.web.bind.annotation.CrossOrigin
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
class TrackController(private val musicService: MusicService) {
|
||||
@GetMapping("track/{albumHash}/{trackNumber}")
|
||||
fun getTrackInfo(@PathVariable albumHash: String, @PathVariable trackNumber: Int): TrackInfo {
|
||||
val file = musicService.getMusic(albumHash, trackNumber)
|
||||
val trackFile = Mp3File(file)
|
||||
trackFile.id3v2Tag.artist
|
||||
trackFile.id3v2Tag.apply {
|
||||
return TrackInfo(album, artist, title)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package net.halfbinary.prettyplayerapi.model
|
||||
|
||||
data class TrackInfo(
|
||||
val albumTitle: String,
|
||||
val artist: String,
|
||||
val trackTitle: String
|
||||
)
|
||||
Reference in New Issue
Block a user