Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[POTENTIAL BUG] #1

Open
slashformotion opened this issue Apr 27, 2023 · 1 comment
Open

[POTENTIAL BUG] #1

slashformotion opened this issue Apr 27, 2023 · 1 comment

Comments

@slashformotion
Copy link
Contributor

I set up a minimal working exemple to get a server up and running:

package main

import (
	"fmt"
	"log"

	"github.com/quarckster/go-mpris-server/pkg/server"
	"github.com/quarckster/go-mpris-server/pkg/types"
)

type Root struct{}

// Implement other methods of `pkg.types.OrgMprisMediaPlayer2Adapter`
func (r Root) Raise() error {
	log.Println("Raised")
	return nil
}

func (r Root) Quit() error {
	return nil
}
func (r Root) CanQuit() (bool, error) {
	return true, nil
}
func (r Root) CanRaise() (bool, error) {
	return true, nil
}
func (r Root) HasTrackList() (bool, error) {
	return true, nil
}
func (r Root) Identity() (string, error) {
	return "hello", nil
}
func (r Root) SupportedUriSchemes() ([]string, error) {
	return []string{}, nil
}
func (r Root) SupportedMimeTypes() ([]string, error) {
	return []string{}, nil
}

var _ types.OrgMprisMediaPlayer2Adapter = Root{}

type Player struct{}

var _ types.OrgMprisMediaPlayer2PlayerAdapter = Player{}

func (p Player) Next() error {
	fmt.Println("Next")
	return nil
}
func (p Player) Previous() error {
	fmt.Println("Previous")
	return nil
}
func (p Player) Pause() error {
	fmt.Println("Pause")
	return nil
}
func (p Player) PlayPause() error {
	fmt.Println("PlayPause")
	return nil
}
func (p Player) Stop() error {
	return nil
}
func (p Player) Play() error {
	return nil
}
func (p Player) Seek(offset types.Microseconds) error {
	return nil
}
func (p Player) SetPosition(trackId string, position types.Microseconds) error {
	return nil
}
func (p Player) OpenUri(uri string) error {
	return nil
}
func (p Player) PlaybackStatus() (types.PlaybackStatus, error) {
	return types.PlaybackStatusStopped, nil
}
func (p Player) Rate() (float64, error) {
	return 1.2, nil
}
func (p Player) SetRate(float64) error {
	return nil
}
func (p Player) Metadata() (types.Metadata, error) {
	return types.Metadata{
		TrackId:        "",
		Length:         0,
		ArtUrl:         "",
		Album:          "",
		AlbumArtist:    []string{},
		Artist:         []string{},
		AsText:         "",
		AudioBPM:       0,
		AutoRating:     0.0,
		Comment:        []string{},
		Composer:       []string{},
		ContentCreated: "",
		DiscNumber:     0,
		FirstUsed:      "",
		Genre:          []string{},
		LastUsed:       "",
		Lyricist:       []string{},
		Title:          "",
		TrackNumber:    0,
		Url:            "",
		UseCount:       0,
		UserRating:     0.0,
	}, nil
}
func (p Player) Volume() (float64, error) {
	return 0, nil
}
func (p Player) SetVolume(in float64) error {
	fmt.Printf("SetVolume %f\n", in)

	return nil
}
func (p Player) Position() (int64, error) {
	return 0, nil
}
func (p Player) MinimumRate() (float64, error) {
	return 0, nil
}
func (p Player) MaximumRate() (float64, error) {
	return 0, nil
}
func (p Player) CanGoNext() (bool, error) {
	return true, nil
}
func (p Player) CanGoPrevious() (bool, error) {
	return true, nil
}
func (p Player) CanPlay() (bool, error) {
	return true, nil
}
func (p Player) CanPause() (bool, error) {
	return true, nil
}
func (p Player) CanSeek() (bool, error) {
	return true, nil
}
func (p Player) CanControl() (bool, error) {
	return true, nil
}

func main() {
	r := Root{}
	p := Player{}
	s := server.NewServer("helloplayer", r, p)
	// _ = events.NewEventHandler(s)
	go s.Listen()
	// some blocking call should be here
	select {}
}

And i got

$ go run main.go
dbus: dropping invalid reply to org.freedesktop.DBus.Properties.GetAll on obj /org/mpris/MediaPlayer2: dbus: wire format error: invalid object path

I don't know if it is a problem on my part or not...

It seems that the functions on org.mpris.MediaPlayer2 works but not on org.mpris.MediaPlayer2.Player

@dweymouth
Copy link
Contributor

Both the Root and Player functions work for me. The invalid object path error may be related to using an empty string as TrackID but I also think it might not be a problem as long as you return valid dbus paths for TrackID once you actually have a track playing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants