示例#1
0
	player.onStopped.addListener(function _handleStopped() {
		// only once
		player.onStopped.removeListener(_handleStopped);

		lastfm.scrobble(timestamp, track)
			.then(() => logger.info('scrobbled'))
			.catch((error) => logger.info('scrobbling error:', error));
	});
示例#2
0
function clearScrobblingTimeout() {
	clearTimeout(scrobbleTimeout);
}

player.onPaused.addListener(clearScrobblingTimeout);
player.onStopped.addListener(clearScrobblingTimeout);

player.onPlaying.addListener(track => {
	if (track.duration > SCROBBLING_MIN_LENGTH) {
		setScrobblingTimeout(track);
		player.onResumed.addListener(setScrobblingTimeout);
	}
});

if (SCROBBLING_NOW_PLAYING) {
	player.onPlaying.addListener(lastfm.nowPlaying);
	player.onResumed.addListener(lastfm.nowPlaying);
}

lastfm.getProfile()
	.then((user) => {
		ui.update({
			user: user,
			scrobbling: SCROBBLING_ENABLED,
			nowPlaying: SCROBBLING_NOW_PLAYING
		});

		ui.show();
	});