Can skip to a random track on double click
This commit is contained in:
parent
677f93723b
commit
19fa419d89
7 changed files with 83 additions and 0 deletions
|
|
@ -162,6 +162,21 @@ func declareInputsRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
|||
|
||||
c.JSON(http.StatusOK, true)
|
||||
})
|
||||
streamRoutes.POST("/next_random_track", func(c *gin.Context) {
|
||||
input, ok := c.MustGet("input").(inputs.PlaylistInput)
|
||||
if !ok {
|
||||
c.AbortWithStatusJSON(http.StatusMethodNotAllowed, gin.H{"errmsg": "The source doesn't support that"})
|
||||
return
|
||||
}
|
||||
|
||||
err := input.NextRandomTrack()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusMethodNotAllowed, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, true)
|
||||
})
|
||||
streamRoutes.POST("/prev_track", func(c *gin.Context) {
|
||||
input, ok := c.MustGet("input").(inputs.PlaylistInput)
|
||||
if !ok {
|
||||
|
|
|
|||
|
|
@ -194,6 +194,28 @@ func declareSourcesRoutes(cfg *config.Config, router *gin.RouterGroup) {
|
|||
|
||||
c.JSON(http.StatusOK, true)
|
||||
})
|
||||
sourcesRoutes.POST("/next_random_track", func(c *gin.Context) {
|
||||
src := c.MustGet("source").(sources.SoundSource)
|
||||
|
||||
if !src.IsActive() {
|
||||
c.AbortWithStatusJSON(http.StatusNotAcceptable, gin.H{"errmsg": "Source not active"})
|
||||
return
|
||||
}
|
||||
|
||||
s, ok := src.(inputs.PlaylistInput)
|
||||
if !ok || !s.HasPlaylist() {
|
||||
c.AbortWithStatusJSON(http.StatusMethodNotAllowed, gin.H{"errmsg": "The source doesn't support"})
|
||||
return
|
||||
}
|
||||
|
||||
err := s.NextRandomTrack()
|
||||
if err != nil {
|
||||
c.AbortWithStatusJSON(http.StatusMethodNotAllowed, gin.H{"errmsg": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, true)
|
||||
})
|
||||
sourcesRoutes.POST("/prev_track", func(c *gin.Context) {
|
||||
src := c.MustGet("source").(sources.SoundSource)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue