Netflix Instant Player (silverlight) 的 Javascript API? [英] Javascript API for Netflix Instant Player (silverlight)?

查看:19
本文介绍了Netflix Instant Player (silverlight) 的 Javascript API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Netflix 即时播放器 (silverlight) 是否有 Javascript API?最好是受支持的、有记录的,但不受支持、无记录的也可能没问题;这是一个个人项目.

我希望能够播放/暂停并寻找给定的时间.

解决方案

我很高兴深入研究这个问题,我想我找到了你的答案.

首先,我发现了 Netflix 某人的一篇(不可否认的旧)帖子,指出他们的许可要求禁止他们提供从外部控制播放器的方法(一切都需要包含在 Netflix 品牌的应用程序中,并提供方法在外部与播放器交互将允许您将 netflix 播放器嵌入它不应该去的地方.)您可以在此处找到该回复(虽然它已经四年了,但我想没有太大变化.)

http://developer.netflix.com/forum/read/54172

我自己尝试在立即观看"页面上四处窥探,其中有像 netflix.SilverLight 和 netflix.SilverLight.MoviePlayer 这样的对象(它有一个 getPlugin() 方法,可以返回有关插件的一些详细信息和可挂钩事件,但没有控制方法,)但它们主要与暴露播放器视口的大小有关,以及将其放置在页面上所需的其他内容.我在任何对象中都找不到任何暗示它们与电影播放器​​进行交互的内容,这些内容似乎允许我访问它.

我还获取了播放器二进制文件,并通过它们窥探我在内部发现了一个 ScriptInterface 对象,其中包含 [ScriptableMember] 装饰的方法,称为 PlayMovie()、StopMovie()、ShowCurtain()、HideCurtain().

然后,我注意到播放器二进制文件中有另一个命名空间,名为 Netflix.Silverlight.CBPApp.HostedPlayer,它有自己的接口 - HostedPlayerScriptInterface.这里面有你想要的一切 - 播放位置的数据,控制播放速度的增加和减少,暂停,播放,设置播放位置,查询播放状态等.所有这些都装饰为 [ScriptableMember]s.

现在我伤了你的心 - 看起来(无论出于何种原因)这个接口没有作为 [ScriptableType] 公开,据我所知,这是能够从 javascript 访问它的要求.事实上,唯一以这种方式暴露的东西是玩家触发的事件.我的猜测是这段代码是为了与其他合作伙伴集成,或者是从他们继承视频播放器原始代码的人那里遗留下来的,但似乎有意省略了这个 [ScriptableType] 参数.可能有一种方法可以请求构建为托管"的二进制文件,尽管我不确定这意味着什么,而且我也怀疑这对于观看您正在尝试做的事情并拥有一个快停下来.

对于以失望告终的冗长回应,我深表歉意,但目前似乎没有真正的方法可以做到这一点.我已经看到一些建议,基本上相当于将击键发送到模拟键盘控件的浏览器窗口,但这显然不是您要查找的内容,因此我将在此处使用否"作为答案.:)

进一步的研究表明,这并不是我认为的死胡同.我会在挖掘完成后更新这个.

编辑 2:

因此,看起来您需要诱使 Netflix 播放器认为它在托管播放器模式下运行.有一些配置选项可以传入,但我不确定具体如何执行.看起来这一切都是在播放器初始化时设置的 - 也许某种书签可以重新加载页面并注入更改?或者也许只是重新加载播放器并更改设置.

this.PlayerViewModel = (applicationConfiguration.PlayerConfiguration.EnableHostedPlayerControl ? new HostedPlayerViewModel() : new GenesisPlayerViewModel());

这是我想出来的地方.使用 HostedPlayerViewModel 时,运行此代码:

HtmlPage.RegisterScriptableObject("HostedPlayerControlScriptInterface_1", this.b)

如果我没看错的话,你可以通过获取包含 netflix silverlight 播放器的 DOM 对象并调用来访问这个注册的对象

silverlightPlayer.content.findName('HostedPlayerControlScriptInterface_1').WhateverMethod()

请记住,我还没有做过很多此类 javascript 互操作性的工作,其中大部分内容都是从文档中推断出来的,但似乎那里确实有一个 javascript 控件 API,这只是欺骗玩家的问题进入托管模式.

不得不停在这里,但希望这能给你一个好的开始.我已经转储了该托管播放器 Javascript API 文件的内容,以便您可以看到一旦您设法将播放器置于托管模式后将公开的方法.

http://pastebin.com/UeN3NFMg

祝你好运!

Is there a Javascript API for the Netflix Instant player (silverlight)? Preferably a supported, documented one, but an unsupported, undocumented one might be okay too; this is for a personal project.

I'd like to be able to play/pause and seek to a given time.

解决方案

I had fun digging into this, and I think I found your answer.

To start, I found an (admittedly old) post from someone at Netflix stating that their licensing requirements prohibited them from providing ways to control the player externally (everything needed to be wrapped up in a netflix-branded application, and providing ways to interact with the player externally would allow you to embed the netflix player in places it shouldn't go.) You can find that reply here (although it's four years old, I'd imagine not much has changed.)

http://developer.netflix.com/forum/read/54172

I tried snooping around on the 'watch instantly' page myself, and there are objects like netflix.SilverLight and netflix.SilverLight.MoviePlayer (which has a getPlugin() method that returns some details about the plugin, and hookable events, but no methods for control,) but they mostly have to do with exposing the size of the player viewport, among other things necessary to place it on the page. I couldn't really find anything in any of the objects that suggested they interacted with the movie player that would seem to allow me access to it.

I also snagged the player binaries, and snooping through them I've found a ScriptInterface object internally with [ScriptableMember]-decorated methods in it called PlayMovie(), StopMovie(), ShowCurtain(), HideCurtain().

Then, I noticed there's another namespace in the player binaries called Netflix.Silverlight.CBPApp.HostedPlayer, which has its own interface - HostedPlayerScriptInterface. This has everything you want in it - data on play position, controls for increasing and decreasing play speed, pausing, playing, setting the play position, querying play state, etc. All of these are decorated as [ScriptableMember]s.

Now I break your heart - it looks like (for whatever reason) this interface is not exposed as a [ScriptableType], which to my understanding is a requirement for being able to access it from javascript. In fact, the only things that seem to be exposed this way are events that the player fires. My guess is that this code is for integrating with other partners, or left over from someone they inherited the original code for the video player from, but it seems intentionally that this [ScriptableType] parameter is left out. There may be a way to request a binary that's built to be 'Hosted', though I'm not sure what that means, and I also suspect it will be transparently obvious to the people watching what you're trying to do and have a stop put to it quickly.

Sorry for the long-winded response that ends in disappointment, but it appears as of right now there's not really a way to do this. I've seen some suggestions that basically amount to sending keystrokes to the browser window that emulate the keyboard controls, but this clearly isn't what you're looking for, so I'm going to go with 'no' as an answer here. :)

Edit:

Further research is showing this is not the dead end that I thought it was. I'll update this once I'm done digging.

Edit 2:

So, looks like you need to trick the Netflix player into thinking it's running in hosted player mode. There's some configuration options that can be passed in, but I'm not sure how, specifically, you would do that. It looks like that's all set up on player initialization - maybe some sort of bookmarklet could reload the page and inject a change? Or maybe just reload the player and change the settings.

this.PlayerViewModel = (applicationConfiguration.PlayerConfiguration.EnableHostedPlayerControl ? new HostedPlayerViewModel() : new GenesisPlayerViewModel());

Is where I figured that out. When the HostedPlayerViewModel is used, this code gets run:

HtmlPage.RegisterScriptableObject("HostedPlayerControlScriptInterface_1", this.b)

which if I'm reading correctly will let you access this registered object by getting the DOM object containing the netflix silverlight player and calling

silverlightPlayer.content.findName('HostedPlayerControlScriptInterface_1').WhateverMethod()

Bear in mind I haven't done much of this javascript interop stuff so much of this is inferred from the documentation, but it does seem as if there is a javascript control API in there, it's just a matter of tricking the player into working in Hosted mode.

Going to have to stop here, but hopefully this gives you a good start. I've dumped the contents of that hosted player Javascript API file so you can see the methods that will be exposed once you manage to get the player in Hosted mode.

http://pastebin.com/UeN3NFMg

Good luck!

这篇关于Netflix Instant Player (silverlight) 的 Javascript API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆