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

Add support for nicecream.fm connector #4513

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ahnesther
Copy link
Contributor

Addresses #4398.
Describe the changes you made
Added connector file for nicecream.fm. Had a bit of a head scratcher on first attempt at why the scrobbler wasn't detecting songs, but it was because of the iframes (had to add another url for nicefm).

Additional context
N/A

@inverse inverse added new-feature For PRs that add new functionality patch-change For patch changes labels Feb 13, 2024
Connector.playButtonSelector = '.controls-wrapper .play-small.on';
Connector.pauseButtonSelector = '.controls-wrapper .play-small.off';

Connector.isPlaying = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be removed and we could just use

Connector.playButtonSelector = '.controls-wrapper .play-small.off';

We don't need to define isPlaying and pauseButtonSelector as well

Copy link
Contributor Author

@ahnesther ahnesther Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 55e1817

Copy link
Member

@inverse inverse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aside the comments LGTM

@ahnesther
Copy link
Contributor Author

ahnesther commented Feb 14, 2024

Aside the comments LGTM

Hold on, there is an issue I'm seeing on Firefox and Chrome (Windows 10). If I'm on nicecream.fm while scrobbling (green playing icon), switch to another tab, then come back to nicecream.fm, it goes from the playing icon to the red base icon. It does seem like the song is still scrobbling and the red base icon disappears if I change channels. Did a quick check on Youtube and Spotify and neither of them have this issue.

Edit: so, adding back the Connector.isPlaying with Util.isElementVisible stops the issue for Chrome but not Firefox. Was there a problem like this before @inverse?

edit2: Adding back the piece of code in first edit doesn't matter. It seems like the icon in Chrome is persisted regardless without isPlaying but doesn't seem to for Firefox, though a few times it did seem to persist for Firefox (maybe once every 20 reloads).

@ahnesther
Copy link
Contributor Author

Still works fine on Chrome.

On Firefox, it seems like the icon doesn't change if I'm on nicecream.fm for a while without the music playing. After I play the music and switch around tabs, the now playing icon doesn't budge. If I close nicecream.fm, reopen it, play music, and switch tabs, the now playing icon is gone and instead the base icon shows.

@inverse
Copy link
Member

inverse commented Feb 14, 2024

Interesting - @yayuyokitano perhaps you have some insights here? For me it's working with the suggestion on Chrome.

@yayuyokitano
Copy link
Member

Not sure what's going on there, try enabling debug logs in advanced settings and seeing whats going on in the console.

Could the issue be related to extension being hot reloaded somehow? Does the issue still occur if you have one firm build, reload extension, and refresh the page?

@ahnesther
Copy link
Contributor Author

ahnesther commented Feb 14, 2024

Not sure what's going on there, try enabling debug logs in advanced settings and seeing whats going on in the console.

Could the issue be related to extension being hot reloaded somehow? Does the issue still occur if you have one firm build, reload extension, and refresh the page?

  1. So I checked the logs and to my eye there isn't anything that really stood out from them. Rather, I noticed something omitted:
    When the song in the radio/player/tab is updated (ie. loading -> playing, playing -> scrobbled, etc), there is a console log message that says changed mode to some_mode in tab xxx. When I switch out to another tab and go back to the player, there is no message about switching modes though the mode changes to Base.
    firefox dev advanced debug log.zip

  2. Unfortunately yeah. I've tried removing the extension, making a new build, loading that new build, restarting the whole browser. Definitely persists strongly for Firefox and to a much less amount for Chrome.

@ahnesther ahnesther marked this pull request as draft February 15, 2024 00:30
@ahnesther
Copy link
Contributor Author

ahnesther commented Feb 15, 2024

Noted some weird inconsistencies with Chrome where the icon does change to the Base, but it seemed to clear away after clearing history, restarting Chrome, removing the extension, making and adding a new build. Didn't add logs because they looked pretty similar to the ones I posted above. Cause for alarm?

@inverse
Copy link
Member

inverse commented Feb 16, 2024

I haven't noticed anything odd when testing things :/

Web Scrobbler: Controller: isPlaying state changed to false [main.js:1:53510](moz-extension://ba4887d7-d218-4aae-918b-196a6b52e604/content/main.js)
Web Scrobbler: Controller: isPlaying state changed to true [main.js:1:53510](moz-extension://ba4887d7-d218-4aae-918b-196a6b52e604/content/main.js)
Web Scrobbler: Controller: isPlaying state changed to false

when enabling debug mode I enabled these logs when pausing/resuming - multiple isPlaying but It doesn't effect scrobbling or pause state.

@yayuyokitano
Copy link
Member

When the song in the radio/player/tab is updated (ie. loading -> playing, playing -> scrobbled, etc), there is a console log message that says changed mode to some_mode in tab xxx. When I switch out to another tab and go back to the player, there is no message about switching modes though the mode changes to Base.

This indicates that the error is probably not in the connector/tab controller. The controller is having the correct mode, but for some reason the service worker is using the wrong tab for setting the icon.

Does this happen with other connectors too?

Maybe it's related to iframe stuff somehow.

@ahnesther
Copy link
Contributor Author

ahnesther commented Feb 18, 2024

When the song in the radio/player/tab is updated (ie. loading -> playing, playing -> scrobbled, etc), there is a console log message that says changed mode to some_mode in tab xxx. When I switch out to another tab and go back to the player, there is no message about switching modes though the mode changes to Base.

This indicates that the error is probably not in the connector/tab controller. The controller is having the correct mode, but for some reason the service worker is using the wrong tab for setting the icon.

Does this happen with other connectors too?
I tested all the allFrames = true connectors. For my initial testing, I was using the Firefox default privacy mode (no cookies/caches saved, etc) and thought the result might be different if I allowed Firefox to save cookies/history, etc since I use Chrome "regularly" (save history/cookies/cache). After turning on saving cookies/history/cache and manually opening a private session of Firefox, there was no difference between the default private and regular cookie saved Firefox.

  • Daily Bandcamp and Regular bandcamp pages work fine for Chrome and Firefox.
  • Bandcampr works fine for Chrome and Firefox
  • Tunegenie (Firefox, and chrome though to a lesser extent)
  • NoiseFM (chrome and firefox)
  • Discogs (cannot get scrobbler to detect song, for both the embedded youtube player and apple music, so I can't test)
  • 9128.live/ (Firefox and rarely Chrome): The icon changes are weird.
    Sometimes clicking between icons doesn't change the icon, but as you keep clicking between tabs, the icon turns from now playing -> grey base in another tab, and once you click on the NoiseFM tab again, sometimes it goes back to now playing but most of the time the icon is the red base icon.
  • super45.fm (Firefox, Firefox Private, Chrome)
  • DatPiff (cannot test as they don't seem to have a player/embedded videos)
  • Abord de l'eau work fine (Firefox, Chrome)
  • WBRU (works fine on Chrome, Firefox Private & Firefox does not work)
  • Bagel Radio (browsers don't detect music playing, so cannot test)
  • Tunegenie embedded (couldnt' test because hard to find places that embed tunegenie tracks)

With 9128, switching between tabs didn't result in any mode change logs in the console.

Maybe it's related to iframe stuff somehow.

Yeah, it does seem like it, though the problem is much more pronounced on Firefox for some reason.

@ahnesther
Copy link
Contributor Author

Would using the developer version of Firefox make a difference?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature For PRs that add new functionality patch-change For patch changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants