add more to track info dialog
This commit is contained in:
@@ -14,7 +14,11 @@ func GetSimilarSongsFallback(mp mediaprovider.MediaProvider, track *mediaprovide
|
|||||||
tracks, _ = mp.GetSimilarTracks(track.ArtistIDs[0], count)
|
tracks, _ = mp.GetSimilarTracks(track.ArtistIDs[0], count)
|
||||||
}
|
}
|
||||||
if len(tracks) == 0 {
|
if len(tracks) == 0 {
|
||||||
tracks, _ = mp.GetRandomTracks(track.Genre, count)
|
genre := ""
|
||||||
|
if len(track.Genres) > 0 {
|
||||||
|
genre = track.Genres[0]
|
||||||
|
}
|
||||||
|
tracks, _ = mp.GetRandomTracks(genre, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure to exclude the song itself from the similar list
|
// make sure to exclude the song itself from the similar list
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package mediaprovider
|
package mediaprovider
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
// Bit field flag for the ReleaseTypes property
|
// Bit field flag for the ReleaseTypes property
|
||||||
type ReleaseType = int32
|
type ReleaseType = int32
|
||||||
|
|
||||||
@@ -90,7 +92,7 @@ type Track struct {
|
|||||||
Duration int
|
Duration int
|
||||||
TrackNumber int
|
TrackNumber int
|
||||||
DiscNumber int
|
DiscNumber int
|
||||||
Genre string
|
Genres []string
|
||||||
ArtistIDs []string
|
ArtistIDs []string
|
||||||
ArtistNames []string
|
ArtistNames []string
|
||||||
Album string
|
Album string
|
||||||
@@ -100,6 +102,7 @@ type Track struct {
|
|||||||
Favorite bool
|
Favorite bool
|
||||||
Size int64
|
Size int64
|
||||||
PlayCount int
|
PlayCount int
|
||||||
|
LastPlayed time.Time
|
||||||
FilePath string
|
FilePath string
|
||||||
BitRate int
|
BitRate int
|
||||||
ContentType string
|
ContentType string
|
||||||
|
|||||||
@@ -500,6 +500,15 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
rGain.AlbumPeak = rg.AlbumPeak
|
rGain.AlbumPeak = rg.AlbumPeak
|
||||||
rGain.TrackPeak = rg.TrackPeak
|
rGain.TrackPeak = rg.TrackPeak
|
||||||
}
|
}
|
||||||
|
var genres []string
|
||||||
|
if len(ch.Genres) > 0 {
|
||||||
|
genres = sharedutil.MapSlice(ch.Genres, func(idName subsonic.IDName) string {
|
||||||
|
return idName.Name
|
||||||
|
})
|
||||||
|
} else if ch.Genre != "" {
|
||||||
|
genres = []string{ch.Genre}
|
||||||
|
}
|
||||||
|
|
||||||
return &mediaprovider.Track{
|
return &mediaprovider.Track{
|
||||||
ID: ch.ID,
|
ID: ch.ID,
|
||||||
CoverArtID: ch.CoverArt,
|
CoverArtID: ch.CoverArt,
|
||||||
@@ -508,7 +517,7 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
Duration: ch.Duration,
|
Duration: ch.Duration,
|
||||||
TrackNumber: ch.Track,
|
TrackNumber: ch.Track,
|
||||||
DiscNumber: ch.DiscNumber,
|
DiscNumber: ch.DiscNumber,
|
||||||
Genre: ch.Genre,
|
Genres: genres,
|
||||||
ArtistIDs: artistIDs,
|
ArtistIDs: artistIDs,
|
||||||
ArtistNames: artistNames,
|
ArtistNames: artistNames,
|
||||||
Album: ch.Album,
|
Album: ch.Album,
|
||||||
@@ -517,12 +526,14 @@ func toTrack(ch *subsonic.Child) *mediaprovider.Track {
|
|||||||
Rating: ch.UserRating,
|
Rating: ch.UserRating,
|
||||||
Favorite: !ch.Starred.IsZero(),
|
Favorite: !ch.Starred.IsZero(),
|
||||||
PlayCount: int(ch.PlayCount),
|
PlayCount: int(ch.PlayCount),
|
||||||
|
LastPlayed: ch.Played,
|
||||||
FilePath: ch.Path,
|
FilePath: ch.Path,
|
||||||
Size: ch.Size,
|
Size: ch.Size,
|
||||||
BitRate: ch.BitRate,
|
BitRate: ch.BitRate,
|
||||||
ContentType: ch.ContentType,
|
ContentType: ch.ContentType,
|
||||||
Comment: ch.Comment,
|
Comment: ch.Comment,
|
||||||
BPM: ch.BPM,
|
BPM: ch.BPM,
|
||||||
|
ReplayGain: rGain,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -254,7 +254,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
|
|||||||
var meta mediaprovider.MediaItemMetadata
|
var meta mediaprovider.MediaItemMetadata
|
||||||
// metadata that can come only from tracks
|
// metadata that can come only from tracks
|
||||||
var discNumber, trackNumber, userRating, playCount, year int
|
var discNumber, trackNumber, userRating, playCount, year int
|
||||||
var genre string
|
var genres []string
|
||||||
|
|
||||||
if np := m.pm.NowPlaying(); np != nil && status.State != player.Stopped {
|
if np := m.pm.NowPlaying(); np != nil && status.State != player.Stopped {
|
||||||
meta = np.Metadata()
|
meta = np.Metadata()
|
||||||
@@ -264,7 +264,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
|
|||||||
userRating = track.Rating
|
userRating = track.Rating
|
||||||
playCount = track.PlayCount
|
playCount = track.PlayCount
|
||||||
year = track.Year
|
year = track.Year
|
||||||
genre = track.Genre
|
genres = track.Genres
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var artURL string
|
var artURL string
|
||||||
@@ -284,9 +284,7 @@ func (m *MPRISHandler) Metadata() (types.Metadata, error) {
|
|||||||
UserRating: float64(userRating) / 5,
|
UserRating: float64(userRating) / 5,
|
||||||
UseCount: playCount,
|
UseCount: playCount,
|
||||||
ArtUrl: artURL,
|
ArtUrl: artURL,
|
||||||
}
|
Genre: genres,
|
||||||
if genre != "" {
|
|
||||||
mprisMeta.Genre = []string{genre}
|
|
||||||
}
|
}
|
||||||
if year != 0 {
|
if year != 0 {
|
||||||
mprisMeta.ContentCreated = strconv.Itoa(year)
|
mprisMeta.ContentCreated = strconv.Itoa(year)
|
||||||
|
|||||||
@@ -866,6 +866,21 @@ func (c *Controller) ShowTrackInfoDialog(track *mediaprovider.Track) {
|
|||||||
pop.Hide()
|
pop.Hide()
|
||||||
c.doModalClosed()
|
c.doModalClosed()
|
||||||
}
|
}
|
||||||
|
info.OnNavigateToAlbum = func(albumID string) {
|
||||||
|
info.OnDismiss()
|
||||||
|
c.NavigateTo(AlbumRoute(albumID))
|
||||||
|
}
|
||||||
|
info.OnNavigateToArtist = func(artistID string) {
|
||||||
|
info.OnDismiss()
|
||||||
|
c.NavigateTo(ArtistRoute(artistID))
|
||||||
|
}
|
||||||
|
info.OnNavigateToGenre = func(genre string) {
|
||||||
|
info.OnDismiss()
|
||||||
|
c.NavigateTo(GenreRoute(genre))
|
||||||
|
}
|
||||||
|
info.OnCopyFilePath = func() {
|
||||||
|
c.MainWindow.Clipboard().SetContent(track.FilePath)
|
||||||
|
}
|
||||||
c.ClosePopUpOnEscape(pop)
|
c.ClosePopUpOnEscape(pop)
|
||||||
winSize := c.MainWindow.Canvas().Size()
|
winSize := c.MainWindow.Canvas().Size()
|
||||||
popMin := pop.MinSize()
|
popMin := pop.MinSize()
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ package dialogs
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"fyne.io/fyne/v2"
|
"fyne.io/fyne/v2"
|
||||||
"fyne.io/fyne/v2/container"
|
"fyne.io/fyne/v2/container"
|
||||||
"fyne.io/fyne/v2/layout"
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
"fyne.io/fyne/v2/widget"
|
"fyne.io/fyne/v2/widget"
|
||||||
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
"github.com/dweymouth/supersonic/backend/mediaprovider"
|
||||||
"github.com/dweymouth/supersonic/ui/util"
|
"github.com/dweymouth/supersonic/ui/util"
|
||||||
@@ -19,6 +21,8 @@ type TrackInfoDialog struct {
|
|||||||
OnDismiss func()
|
OnDismiss func()
|
||||||
OnNavigateToArtist func(artistID string)
|
OnNavigateToArtist func(artistID string)
|
||||||
OnNavigateToAlbum func(albumID string)
|
OnNavigateToAlbum func(albumID string)
|
||||||
|
OnNavigateToGenre func(genre string)
|
||||||
|
OnCopyFilePath func()
|
||||||
|
|
||||||
track *mediaprovider.Track
|
track *mediaprovider.Track
|
||||||
}
|
}
|
||||||
@@ -53,8 +57,31 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
}
|
}
|
||||||
c.Add(album)
|
c.Add(album)
|
||||||
|
|
||||||
|
if len(t.track.Genres) > 0 {
|
||||||
|
c.Add(newFormText("Genres", true))
|
||||||
|
genres := widgets.NewMultiHyperlink()
|
||||||
|
genres.BuildSegments(t.track.Genres, t.track.Genres)
|
||||||
|
genres.OnTapped = func(g string) {
|
||||||
|
if t.OnNavigateToGenre != nil {
|
||||||
|
t.OnNavigateToGenre(g)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.Add(genres)
|
||||||
|
}
|
||||||
|
|
||||||
addFormRow(c, "Duration", util.SecondsToTimeString(float64(t.track.Duration)))
|
addFormRow(c, "Duration", util.SecondsToTimeString(float64(t.track.Duration)))
|
||||||
addFormRow(c, "File path", t.track.FilePath)
|
|
||||||
|
copyBtn := widgets.NewIconButton(theme.ContentCopyIcon(), func() {
|
||||||
|
if t.OnCopyFilePath != nil {
|
||||||
|
t.OnCopyFilePath()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
copyBtn.IconSize = widgets.IconButtonSizeSmaller
|
||||||
|
btnCtr := container.New(layout.NewCustomPaddedLayout(8, 0, 10, 0),
|
||||||
|
container.NewVBox(copyBtn, layout.NewSpacer()))
|
||||||
|
c.Add(container.NewHBox(btnCtr, newFormText("File path", true)))
|
||||||
|
c.Add(newFormText(t.track.FilePath, false))
|
||||||
|
|
||||||
addFormRow(c, "Comment", t.track.Comment)
|
addFormRow(c, "Comment", t.track.Comment)
|
||||||
addFormRow(c, "Year", strconv.Itoa(t.track.Year))
|
addFormRow(c, "Year", strconv.Itoa(t.track.Year))
|
||||||
addFormRow(c, "Track number", strconv.Itoa(t.track.TrackNumber))
|
addFormRow(c, "Track number", strconv.Itoa(t.track.TrackNumber))
|
||||||
@@ -69,6 +96,10 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
addFormRow(c, "File size", util.BytesToSizeString(t.track.Size))
|
addFormRow(c, "File size", util.BytesToSizeString(t.track.Size))
|
||||||
addFormRow(c, "Play count", strconv.Itoa(t.track.PlayCount))
|
addFormRow(c, "Play count", strconv.Itoa(t.track.PlayCount))
|
||||||
|
|
||||||
|
if !t.track.LastPlayed.IsZero() {
|
||||||
|
addFormRow(c, "Last played", t.track.LastPlayed.Format(time.RFC1123))
|
||||||
|
}
|
||||||
|
|
||||||
if t.track.ReplayGain.TrackPeak > 0 {
|
if t.track.ReplayGain.TrackPeak > 0 {
|
||||||
addFormRow(c, "Track gain", fmt.Sprintf("%0.2f dB", t.track.ReplayGain.TrackGain))
|
addFormRow(c, "Track gain", fmt.Sprintf("%0.2f dB", t.track.ReplayGain.TrackGain))
|
||||||
addFormRow(c, "Track peak", fmt.Sprintf("%0.6f", t.track.ReplayGain.TrackPeak))
|
addFormRow(c, "Track peak", fmt.Sprintf("%0.6f", t.track.ReplayGain.TrackPeak))
|
||||||
@@ -94,12 +125,16 @@ func (t *TrackInfoDialog) CreateRenderer() fyne.WidgetRenderer {
|
|||||||
container.NewHBox(layout.NewSpacer(), dismissBtn),
|
container.NewHBox(layout.NewSpacer(), dismissBtn),
|
||||||
),
|
),
|
||||||
/*left/right*/ nil, nil,
|
/*left/right*/ nil, nil,
|
||||||
/*center*/ container.NewScroll(c),
|
/*center*/ container.New(layout.NewCustomPaddedLayout(10, 10, 15, 15),
|
||||||
|
container.NewScroll(c)),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addFormRow(c *fyne.Container, left, right string) {
|
func addFormRow(c *fyne.Container, left, right string) {
|
||||||
|
if right == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
c.Add(newFormText(left, true))
|
c.Add(newFormText(left, true))
|
||||||
c.Add(newFormText(right, false))
|
c.Add(newFormText(right, false))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user