Control Netflix player using JavaScript
Asked Answered
J

1

12

I would like to make a Chrome extension that is able to control the Netflix player.

The current Netflix player is written in HTML5 as far as I can tell, so I was wondering if there is a way to control the player, e.g. play, pause, volume control and changing the position of the video.

I've tried using this to control the playing and pausing functions and it works.

document.getElementsByClassName("player-control-button player-play-pause")[0].click();

I've also tried using but then I just get an error saying that videoPlayer() isn't a function

netflix.cadmium.objects.videoPlayer();

Is there something similar I can do to change the volume and the position of the video?

Thanks!

Jacquelynnjacquenetta answered 20/11, 2015 at 15:34 Comment(1)
Netflix offers keyboard shortcuts (help.netflix.com/en/node/24855) for most of the controls you have mentioned. Perhaps you could just fire a keyboard event? #962032. The only thing you'll be able to do is seek to a particular time.Tezel
B
5

First get the <video> element as variable e.g. by:

media = document.getElementsByTagName("video")[0];

After that you can control the volume. To mute the sound:

media.volume = 0

Turn the volume to 100%:

media.volume = 1

Turn the volume to 60%:

media.volume = 0.6

Start the video:

media.start();

Pause the video:

media.pause();
Biome answered 18/11, 2019 at 13:52 Comment(1)
media = document.getElementsByTagName("video")[0]; and it works in 2021 - even for interactive netflix movies.Boggle

© 2022 - 2024 — McMap. All rights reserved.