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

[DEPRECATED] Chromecast Plugin #296

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented May 23, 2021

Implement and closes #289

This plugin connects to all nearby Chromecast devices and stream youtube music with video

Sync Options:

  • Seek - sync current time on Chromecast when current time is changed in local video
  • StartTime - wait for Chromecast to start playback before local playback begins
  • Volume - self explanatory

Features Tested by @playday3008 - who originally requested this plugin

I can't see why snyk failed the security test (access error - not a member of organization)

Copy link
Owner

@th-ch th-ch left a comment

Choose a reason for hiding this comment

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

Thanks for the addition! Did not test it with a real chromecast device yet, but looks promising! Left a few first comments - about the security issue reported by Snyk, [email protected] introduces [email protected] which has a Remote Memory Exposure vulnerability, fixed in [email protected]. Until the chromecast package has an update for this, the version can be forced with a resolution "dns-packet": "5.2.4", in package.json:

"yargs-parser": "18.1.3"

(note that it's not the same major version so worth manually testing that everything works correctly!)

function transformURL(url) {// will not be needed after https://github.com/alxhotel/chromecast-api/pull/69 (chromecastAPI v0.3.5)
const videoId = url.match(/(?:http(?:s?):\/\/)?(?:www\.)?(?:music\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)/);
// videoId[1] should always be valid since regex should always be valid
return "https://youtube.com/watch?v=" + (videoId.length > 1 ? videoId[1] : "dQw4w9WgXcQ");
Copy link
Owner

Choose a reason for hiding this comment

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

Nice Rickroll 🙃 Maybe worth a comment in code, I wondered why this hardcoded ID was there at first 😅

Copy link
Collaborator Author

@Araxeus Araxeus Jun 19, 2021

Choose a reason for hiding this comment

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

There is a comment already 😅
I thought the module would update its version faster - and this method will be unneeded
but sadly it hasn't happened yet - the fix pr was merged but the npm version wasn't updated yet

(method should only be called when songInfo is updated which means the url regex is valid - which means you should never get rick-rolled 😝)

@@ -12,8 +12,7 @@ module.exports = (win) => {
// Playback
previous: () => pressKey(win, "k"),
next: () => pressKey(win, "j"),
playPause: () => win.webContents.send("playPause"),
like: () => pressKey(win, "_"),
playPause: (toPlay = undefined) => win.webContents.send("playPause", toPlay),
Copy link
Owner

Choose a reason for hiding this comment

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

I'm getting a Error: Failed to serialize arguments (song-controls.js:15:54) when using the play/pause media key, is it expected?

Copy link
Collaborator Author

@Araxeus Araxeus Jun 19, 2021

Choose a reason for hiding this comment

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

It happened because shortcut plugin call the method with win.webContents argument.
I just fixed it by making play, pause directly part of song controls
sorry about that

Comment on lines 24 to 28
function play() {
video.play();
}

function pause() {
Copy link
Owner

Choose a reason for hiding this comment

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

nit: it might not be necessary to define the 2 inner functions if they are a one-liner and only used once!

Copy link
Collaborator Author

@Araxeus Araxeus Jun 19, 2021

Choose a reason for hiding this comment

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

I agree that play() is unnecessary, but pause() is called in 2 different places

(I originally added play() only because pause() was there - but I removed it as requested)

Comment on lines 37 to 42
if (!video) {
video = document.querySelector("video");
if (!video) {
return false;
}
});
};
} return true;
Copy link
Owner

Choose a reason for hiding this comment

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

nit: it can be simplified into

function checkVideo() {
    if (!video) {
        video = document.querySelector("video");
    }

    return !!video;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done 👍🏼

providers/song-controls.js Show resolved Hide resolved
if (!checkVideo()) return;

switch(toPlay) {
case undefined:
Copy link
Owner

Choose a reason for hiding this comment

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

nit: could also be the default case for the switch, to be defensive

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done 👍🏼

@Araxeus
Copy link
Collaborator Author

Araxeus commented Jun 21, 2021

(note that it's not the same major version so worth manually testing that everything works correctly!)

Tested with latest changes

@playday3008
Copy link

Well, we still need device list with optional auto connection

@Araxeus Araxeus marked this pull request as draft November 1, 2021 21:37
@JellyBrick JellyBrick added need rebase This plugin need rebase enhancement New feature or request labels Oct 7, 2023
@JellyBrick JellyBrick changed the title Chromecast Plugin [DEPRECATED] Chromecast Plugin Dec 27, 2023
@danir-de
Copy link

danir-de commented Jan 5, 2024

This feature would make the app feature complete for me, sadly I cannot help by coding. If there is anything I can do to help to refactor this for the latest version, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request need rebase This plugin need rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Chromecast support
5 participants