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

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

问题描述

Netflix Instant Player(Silverlight)是否有Javascript API?最好是一个受支持的,有记录的,但是一个不受支持的,未记录的一个也可能没问题;这是个人项目。

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.

首先,我找到了来自Netflix的某人的一篇(诚然陈旧的)帖子,声称他们的许可要求禁止他们提供外部控制玩家的方法(所有需要包含在netflix品牌的应用程序中,并提供与外部玩家互动的方式将允许你将netflix播放器嵌入它不应该去的地方。)你可以在这里找到答案(尽管它已经有四年了,但我认为没有太大变化。)

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

我自己试着在立即观看页面上窥探,还有像netflix.SilverLight和netflix.SilverLigh这样的对象。 t.MoviePlayer(它有一个getPlugin()方法,它返回有关插件和钩子事件的一些细节,但是没有控制方法,但是它们主要与暴露玩家视口的大小有关,除了其他必要的东西之外)把它放在页面上。我无法在任何建议他们与电影播放器​​互动的对象中找到任何似乎允许我访问它的内容。

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.

我还抓住了播放器二进制文件,窥探它们我在内部发现了一个ScriptInterface对象,其中包含[ScriptableMember] - 解决方法,称为PlayMovie(),StopMovie(),ShowCurtain(),HideCurtain()。

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().

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

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.

现在我打破了你的心 - 看起来(无论出于什么原因)这个界面没有作为[ScriptableType]公开,据我所知,这是一个能够从javascript访问它的要求。事实上,似乎只有这种方式暴露的事情是玩家开火的事件。我的猜测是这段代码是为了与其他合作伙伴集成,或者是从他们继承了视频播放器的原始代码的人那里留下来的,但似乎故意忽略了这个[ScriptableType]参数。可能有一种方法可以请求构建为托管的二进制文件,但我不确定这意味着什么,而且我也怀疑对于那些正在尝试做什么的人来说它会显而易见很快就停止了。

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. :)

编辑:

进一步的研究表明,这不是我认为的死胡同。一旦我完成挖掘,我就会更新。

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

编辑2:

所以,看起来像你需要欺骗Netflix玩家认为它在托管播放器模式下运行。有一些配置选项可以传入,但我不确定具体如何,你会这样做。看起来这些都是在播放器初始化时设置的 - 也许某种书签可以重新加载页面并注入更改?或者只是重新加载播放器并更改设置。

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());

我认为是在哪里。当使用HostedPlayerViewModel时,此代码运行:

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

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

如果我正确阅读将允许您通过获取包含netflix silverlight播放器的DOM对象来访问此注册对象并调用

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()

请记住,我没有做太多关于这个javascript互操作的东西,所以从文档中推断出这么多,但它看起来好像在那里这是一个javascript控件API,它只是欺骗玩家在托管模式下工作。

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.

必须停在这里,但希望这会给你一个好的开始。我已经转储了托管播放器Javascript API文件的内容,这样您就可以看到一旦设法让玩家处于托管模式就会暴露的方法。

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.

< a href =http://pastebin.com/UeN3NFMg> http://pastebin.com/UeN3NFMg

祝你好运!

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

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