Aylur / ags

A customizable and extensible shell
GNU General Public License v3.0
2.11k stars 109 forks source link

Not able to fetch any players while using Mpris service #342

Closed MohitR1999 closed 6 months ago

MohitR1999 commented 6 months ago

Hi, I've been using ags for a while and it's fantastic. However, I'm running into an issue while trying out the Mpris service. I'm not able to list any players, although I can list them using playerctl. I can control the play pause and other functionalities using playerctl but I wanna make a widget using ags, hope someone can help me out in pointing out what I'm doing wrong.

Attaching the code I'm trying out:

const mpris = await Service.import('mpris');

function Player() {
    print(mpris.players); // prints nothing, even if I have a player running
    return Widget.Button({
        onClicked : () => {
            // player.playPause()
        },

        child : Widget.Label('player')
    })
}

export default Player;

Attaching my system config:

OS: Arch Linux x86_64
Kernel: 6.7.9-arch1-1
DE: Hyprland
Ags version: 1.8.0
Aylur commented 6 months ago

your are accessing it on startup synchronously which will result in an empty array because it looks for available players asynchronously have a look at the exmaple widget on the wiki https://aylur.github.io/ags-docs/services/mpris/#example-widget

MohitR1999 commented 6 months ago

Hi, Thanks a lot man, I was so confused. Now I'm unblocked :)

Thanks and regards, Mohit Ranjan

On Sun, 10 Mar 2024 at 18:38, Aylur @.***> wrote:

your are accessing it on startup synchronously which will result in an empty array because it looks for available players asynchronously have a look at the exmaple widget on the wiki https://aylur.github.io/ags-docs/services/mpris/#example-widget

— Reply to this email directly, view it on GitHub https://github.com/Aylur/ags/issues/342#issuecomment-1987223870, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHNKIYCU72MAPEZOP45KG7TYXRLNNAVCNFSM6AAAAABEOWPPL6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXGIZDGOBXGA . You are receiving this because you authored the thread.Message ID: @.***>