Adds track controller
This commit is contained in:
parent
8b077be945
commit
0c7805eee3
@ -8,7 +8,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "net.halfbinary"
|
||||
version = "0.0.7-SNAPSHOT"
|
||||
version = "0.0.8-SNAPSHOT"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_21
|
||||
|
||||
@ -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
|
||||
)
|
||||
Loading…
x
Reference in New Issue
Block a user