Fix track detection
This commit is contained in:
31
main.go
31
main.go
@@ -166,7 +166,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
content.Wrapping = fyne.TextWrapWord
|
||||
content.Selectable = true
|
||||
icon := theme.FileVideoIcon()
|
||||
replytext := widget.NewLabel("> fallback reply text")
|
||||
replytext := widget.NewLabel(">fallback reply text")
|
||||
replytext.Hide()
|
||||
replytext.Importance = widget.SuccessImportance
|
||||
btn := widget.NewButtonWithIcon("View media", icon, func() {
|
||||
@@ -249,7 +249,7 @@ func CreateUITab(chatJidStr string) ChatTabUI {
|
||||
for i := len(chatTabs[chatJidStr].Messages) - 1; i >= 0; i-- {
|
||||
if reply.ID == chatTabs[chatJidStr].Messages[i].Raw.StanzaID.ID {
|
||||
replytext.Show()
|
||||
replytext.SetText(fmt.Sprintf("> %s", chatTabs[chatJidStr].Messages[i].Content))
|
||||
replytext.SetText(fmt.Sprintf(">%s", chatTabs[chatJidStr].Messages[i].Content))
|
||||
guy = chatTabs[chatJidStr].Messages[i].Author
|
||||
break
|
||||
}
|
||||
@@ -1125,6 +1125,13 @@ func main() {
|
||||
})
|
||||
|
||||
mycurrentplayingsong := fyne.NewMenuItem("Get currently playing song", func() {
|
||||
// BEGIN PLATFORM SPECIFIC CODE
|
||||
if os.PathSeparator == '\\' && os.PathListSeparator == ';' { // Windows
|
||||
dialog.ShowError(errors.New("This feature is not supported on your operating system"), w)
|
||||
return
|
||||
}
|
||||
// END PLATFORM SPECIFIC CODE
|
||||
|
||||
client, err := mpris.NewClient()
|
||||
if err != nil {
|
||||
dialog.ShowError(err, w)
|
||||
@@ -1137,16 +1144,26 @@ func main() {
|
||||
newtext := ""
|
||||
title, t_ok := player.RawMetadata()["xesam:title"]
|
||||
artist, a_ok := player.RawMetadata()["xesam:artist"]
|
||||
if t_ok && a_ok {
|
||||
newtext = fmt.Sprintf("I'm currently listening to %s by %s", title.String(), artist.String())
|
||||
album, al_ok := player.RawMetadata()["xesam:album"]
|
||||
artists := []string{}
|
||||
|
||||
if a_ok{
|
||||
artist.Store(&artists)
|
||||
}
|
||||
|
||||
if t_ok && a_ok && al_ok && album.String() != "\"\""{
|
||||
newtext = fmt.Sprintf("I'm currently listening to %s by %s, in the %s album", strings.Trim(title.String(), "\""), strings.Join(artists, ","), album)
|
||||
} else if t_ok && a_ok {
|
||||
newtext = fmt.Sprintf("I'm currently listening to %s by %s", strings.Trim(title.String(), "\""), strings.Join(artists, ",") )
|
||||
} else if t_ok {
|
||||
newtext = fmt.Sprintf("I'm currently listening to %s", title.String())
|
||||
newtext = fmt.Sprintf("I'm currently listening to %s", strings.Trim(title.String(), "\""))
|
||||
} else if a_ok {
|
||||
newtext = fmt.Sprintf("I'm currently listening to a song by %s", artist.String())
|
||||
newtext = fmt.Sprintf("I'm currently listening to a song by %s", artists[0])
|
||||
} else {
|
||||
dialog.ShowError(errors.New("error: There's a playing song, but we could not get the artist or title information."), w)
|
||||
dialog.ShowError(errors.New("error: There's a playing song, but we could not get any information."), w)
|
||||
return
|
||||
}
|
||||
|
||||
entry.SetText(newtext)
|
||||
SendCallback()
|
||||
entry.SetText(old)
|
||||
|
Reference in New Issue
Block a user