Skip to content

add media-player module#608

Closed
chipsTM wants to merge 5 commits into
SevenTV:masterfrom
chipsTM:feat/media-player
Closed

add media-player module#608
chipsTM wants to merge 5 commits into
SevenTV:masterfrom
chipsTM:feat/media-player

Conversation

@chipsTM
Copy link
Copy Markdown
Contributor

@chipsTM chipsTM commented May 16, 2023

This PR aims to add the foundational work of working with the media player by combining several requested features into one PR.

Player Settings Section
image

Stream info tooltip
image

Showcasing Twitch's auto speed up
image

Successful merge of this PR will close #485 and #562

Comment thread CHANGELOG-nightly.md Outdated
Comment thread src/site/twitch.tv/modules/media-player/MediaPlayer.vue Outdated
Comment thread src/site/twitch.tv/modules/media-player/MediaPlayer.vue Outdated
Comment thread src/site/twitch.tv/modules/media-player/MediaPlayer.vue Outdated
Comment thread src/site/twitch.tv/modules/media-player/MediaPlayer.vue Outdated
Comment thread src/site/twitch.tv/modules/media-player/MediaPlayer.vue Outdated
Copy link
Copy Markdown
Contributor

@AnatoleAM AnatoleAM 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 cleanup so far 🙂


definePropertyHook(props.instance.component, "props", {
value: (v: Twitch.MediaPlayerComponent["props"]) => {
if (v.mediaPlayerInstance) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assign v.mediaPlayerInstance to a ref and use a watcher. You can see an example of this here:
https://github.com/SevenTV/Extension/blob/master/src/site/twitch.tv/modules/chat/ChatController.vue#L246

By doing this we are making vue handle diffing and avoid re-hooking the component many times. This also ensures that if we receive a different pointer, the hooks can be removed from the previous one.

Comment on lines +116 to +121
const videoElement = mediaPlayer.core.mediaSinkManager.video;
if (!videoElement) return;

const overlayContainer = videoElement.nextElementSibling?.querySelector<HTMLElement>(
"div[data-a-target='player-overlay-click-handler']",
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: can avoid optional chaining

Suggested change
const videoElement = mediaPlayer.core.mediaSinkManager.video;
if (!videoElement) return;
const overlayContainer = videoElement.nextElementSibling?.querySelector<HTMLElement>(
"div[data-a-target='player-overlay-click-handler']",
);
const videoElement = mediaPlayer.core.mediaSinkManager.video;
if (!videoElement || !videoElement.nextElementSibling) return;
const overlayContainer = videoElement.nextElementSibling.querySelector<HTMLElement>(
"div[data-a-target='player-overlay-click-handler']",
);

Comment on lines +36 to +41
const rootNode = inst.domNodes.root;
if (rootNode) {
const teleLoc = rootNode.querySelector<HTMLElement>("[data-a-target*='channel-viewers-count']")
?.parentElement?.parentElement?.parentElement;
videoStatsTeleportLocation.value = teleLoc;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: less depth

Suggested change
const rootNode = inst.domNodes.root;
if (rootNode) {
const teleLoc = rootNode.querySelector<HTMLElement>("[data-a-target*='channel-viewers-count']")
?.parentElement?.parentElement?.parentElement;
videoStatsTeleportLocation.value = teleLoc;
}
const rootNode = inst.domNodes.root;
if (!rootNode) return;
const teleLoc = rootNode.querySelector<HTMLElement>("[data-a-target*='channel-viewers-count']")
?.parentElement?.parentElement?.parentElement;
videoStatsTeleportLocation.value = teleLoc;

<p>Video: {{ props.width }}x{{ props.height }}p{{ props.framerate }}</p>
<p>Bitrate: {{ props.bitrate }} kbps</p>
<p>Dropped Frames: {{ props.droppedFrames }}</p>
<br />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: use css instead of <br />

@chipsTM chipsTM mentioned this pull request May 26, 2023
@AnatoleAM
Copy link
Copy Markdown
Contributor

The master branch has its own Player module, please refactor in a new pull request

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

Successfully merging this pull request may close these issues.

2 participants