I have been unable to figure out how to do a video seek (automatically advance to a certain point in the video) in the Netflix video player running in Chrome. The currentTime
property can be read but not set in the Netflix player, and when set, immediately triggers the error "Whoops! Something went wrong.". Other actions such as Play and Pause work quite well. For example, you can try the following:
- Log into Netflix (from Google Chrome) and go to the movie Armageddon.
- After the movie loads, pause it if it starts playing.
- Open the Chrome Developer Tools panel. Go to the Console tab.
- Paste the following snippet into the console and hit
<ENTER>
:
var video = document.evaluate('//*[@id="5670317"]/video',document).iterateNext()
Note: The id value is specific to Armageddon. If you choose a different movie, which is fine, change the id as per the id in the URL of that movie.
- Enter the following and then press
<Enter>
: video.play()
. Observe that the video resumes playing.
Simple enough, but how to make the video auto-advance to a specific point in the video? You may want to refer to this doc. Obviously you can manually seek by dragging the video player slider from left to right and release it someplace. You may wish to discover which method or event is called when you do this, and simulate that. I haven't had luck thus far.
Any ideas?
Finally found a simple solution:
netflix.cadmium.UiEvents.events.resize[1].scope.events.dragend[1].handler(null, {value: 999, pointerEventData: {playing: false}});
You can set:
- position using value property
- playing state using pointerEventData.playing property
It's not complete solution, but can be useful.
Previous version of netflix player was with global object window.netflix.cadmium.objects.videoPlayer. In the recent version it's empty, but you can access this object within events listeners:
- Open Chrome Developer Tools
- Select "body" element
- Select "Event Listeners"
- Turn on "Framework listeners"
- Select "keydown" event, "body" - handler p(e), "[[Scopes]]", 1 [[Closure]]
- You can save this object reference with context menu - "Store as a global variable"
Then in new global variable you can get access to temp1.cadmium.objects.videoPlayer
temp1.cadmium.objects.videoPlayer().getDuration()
temp1.cadmium.objects.videoPlayer().seek(2283839);
temp1.cadmium.objects.videoPlayer().seek(4283839);
[![enter image description here][1]][1]
I am not sure is it possible to do fully automatic. You can get access to this listeners by
getEventListeners(document.getElementsByTagName("body")[0]).keydown[0].listener
But I don't know how to get access to scopes variables
Looks like netflix changed player api. Its what I found:
const videoPlayer = netflix
.appContext
.state
.playerApp
.getAPI()
.videoPlayer
// Getting player id
const playerSessionId = videoPlayer
.getAllPlayerSessionIds()[0]
const player = videoPlayer
.getVideoPlayerBySessionId(playerSessionId)
Now you can use full player API.
For example player.seek
or player.getCurrentTime
or player.pause
, etc...
Building on Dmitry's response jump ahead 10 seconds by
player.seek(player.getCurrentTime() - 10000)