How to interact with the Netflix Cadmium video player on the client?

I have a Netflix account and I looked under the hood of my video player running inside Google Chrome. Netflix calls its video player β€œCadmium,” and javascript provides all the functions and event handlers you might expect, such as play, pause, pause, mute, etc. I am creating a small Chrome extension that would let me name these cadmium players, but the hard part for me is figuring out how to instantiate the player so that I can start making calls. Javascript is large, complex, and somewhat obscure. As soon as I can create an instance of this player, I think making calls in a function will be easy.

Here is the corresponding js snippet:

muteOn: function() { this.savedVolume = this.getVolume(), this.updateVolumeDisplay(0), this.scrubber.updatePercent(0), this.muted = !0, this.videoPlayer.setMuted(this.muted) } 

In Chrome dev tools, I can set a breakpoint inside this block, and execution gets to the breakpoint when I press the Mute button on the netflix video player. Netflix js (unsurprisingly) is very confused by renaming methods. I tried to go through the code in the debugger and finished a hundred rabbit holes, I could never find my way to the top of the stack so that I could make the same call (at the top of the stack) to mimic the user by pressing the mute button. I also tried using a soft click on the mute button on the UI player that would suit my needs equally well, but they have serious defense mechanisms that rotate me like the top.

Since there are more than 100 thousand javascript lines, and I'm not sure which fragments will be relevant to this post, I would like to suggest you download Netflix in Chrome, open the developer tools, play a movie and check the pause or mute. Interacting with these video player controls takes you to a maze of javascript, which I’m trying to understand how I can use to control aspects of the player programmatically (just from the dev tools at the moment it's good). Another important thing I need to find out is how to request a video player to determine the current elapsed video playback time.

Any ideas how I can crack this nut? (Thanks in advance!)

+8
javascript netflix
source share
1 answer

Using Chrome, I get playback using HTML 5 video.

Once you hold the <video> tag element, you can use the HTML 5 video API :

Get the <video> element

 var video = document.evaluate('//*[@id="70143639"]/video',document).iterateNext() 

70143639 is a video identifier, as in https://www.netflix.com/watch/70143639

Time Left (HH: mm)

 document.evaluate('//*[@id="netflix-player"]/div[4]/section[1]/label', document).iterateNext().innerHTML 

Elapsed time (in seconds)

 video.currentTime 

Expired Time Updates

 video.addEventListener("timeupdate", function(e) { console.debug("Seconds elapsed: ", e.timeStamp/1000/60); } ); 

Note that I am not getting the same results as with video.currentTime , you may need to use an offset based on the difference. Something can also be explained in the specification: https://www.w3.org/TR/html5/embedded-content-0.html

Play

 video.play(); 

Pause

 video.pause(); 

Round trip on time

Provided by rebelliard : netflix.cadmium.UiEvents.events.resize[1].scope.events.drageβ€Œβ€‹nd[1].handler(null, {value: 600, pointerEventData: {playing: false}}); where 600 is the number of seconds to search.

Note that I came across "Oops, something went wrong ..." using this:

 video.currentTime += 60; 

Even when pausing and playing calls. This is what this demo page is , you need to read the full specification on the search .

Disable and disable status

 video.muted = true 

Like video.currentTime , this property is for recording.

+5
source share

All Articles