简体   繁体   English

从Silverlight代码外部使Silverlight播放器进入全屏模式

[英]Get the silverlight player into fullscreen mode from outside the silverlight code

I have a silverlight mediaElement embeded in my asp.net page as follow: 我的asp.net页中嵌入了silverlight mediaElement,如下所示:

<object id="SilverlightPlayer" data="data:application/x-silverlight," 
         type="application/x-silverlight-2" width="753" height="468" >
         <param name="source" value="ClientBin/VideoPlayer.xap"/>  
         <param name="EnableGPUAcceleration" value="true" />
         <param name="OnResize" value="HandleResize" />
         <param name="autoUpgrade" value="true" />
         <param name="onLoad" value="pluginLoaded" />
         <param name="windowless" value="true" />
         <param name="background" value="transparent" />
         <param name="initParams" id="SLInitParameters" />                    
</object>     

I am implementing all the player controls from the asp.net side and invoking the SL methods using the javascript bridge. 我正在从asp.net端实现所有播放器控件,并使用javascript桥调用SL方法。 Everything works fine except the ability to put the silverlight player in full screen mode. 除了能够将Silverlight播放器置于全屏模式之外,其他所有功能都正常运行。 content.IsFullScreen = True;

I have tried calling a method from javascript: 我尝试从javascript调用方法:

[ScriptableMember]
public void mediaFullScreen()
{
    var content = Application.Current.Host.Content;
    content.IsFullScreen = !content.IsFullScreen;
}

I put a button in the Silverlight code which works fine. 我在Silverlight代码中放了一个按钮,效果很好。 So, I had the javascript call a the function above. 因此,我让javascript调用了上面的函数。 I then changed the code invoke the click event on the SL full screen button, however, that does not work either: 然后,我更改了在SL全屏按钮上调用click事件的代码,但是,该操作也不起作用:

ButtonAutomationPeer peer = new ButtonAutomationPeer((Button)this.fullScreenButton);
IInvokeProvider ip = (IInvokeProvider)peer;
ip.Invoke(); 

I even wired up an event handler in the SL code to process the click event on the tag: 我什至在SL代码中连接了一个事件处理程序,以处理标签上的click事件:

HtmlDocument htmlDoc = HtmlPage.Document; 
HtmlElement htmlEle = htmlDoc.GetElementById("buttonFullScreen");
htmlEle.AttachEvent("onclick", new EventHandler(this.OnConvertClicked)); 

Is there anyway I can get the SL to go into full screen mode from my tag in the asp.net code? 无论如何,我可以从asp.net代码中的标签让SL进入全屏模式吗? (Using VS2010 and SL4) (使用VS2010和SL4)

Thanks, Dave 谢谢戴夫

From the full screen support documentation: 全屏支持文档中:

A Silverlight-based application can enter full-screen mode only in response to a user-initiated action. 基于Silverlight的应用程序只能响应用户启动的操作才能进入全屏模式。

and: 和:

Limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior. 限制启用全屏模式的操作可确保用户始终是全屏模式行为的发起者。

This is the case also for other things, eg launching an open file dialog. 其他情况也是如此,例如启动一个打开的文件对话框。

If you need to initiate from JavaScript you may have to turn to another approach from the Silverlight full-screen mode, ie maximizing it within the browser. 如果您需要从JavaScript启动,则可能必须转向Silverlight全屏模式的另一种方法,即在浏览器中最大化它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM