首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我能从octane.xam.VideoPlayer插件(XAMARIN表单)截获退出FullScreen事件吗?

我能从octane.xam.VideoPlayer插件(XAMARIN表单)截获退出FullScreen事件吗?
EN

Stack Overflow用户
提问于 2017-11-09 23:55:31
回答 1查看 407关注 0票数 0

我的应用程序的工作portait,ma我想全屏视频播放,甚至在横向模式使用上述插件。

为此,我创建了一个自定义渲染器来访问本机AVPlayerViewController Ios控件。

我尝试了很多方法,但似乎不可能处理退出全屏事件。在该方法中,我想强制布局纵向。我已经实现了重置方向的代码,但问题是将代码放在正确的位置。

还有其他面临同样问题的人吗??

我试着在AVPlayerView(不可访问),AVPlayerVideoController,AVPlayerCurrentItem等中搜索有用的东西

有什么想法吗?

提前谢谢你。

EN

回答 1

Stack Overflow用户

发布于 2017-11-14 15:26:06

我已经为您将此link中的OC代码翻译为C#,请参阅以下代码:

代码语言:javascript
复制
using Foundation;
using CoreGraphics;


playerViewController = new AVPlayerViewController();
playerViewController.ContentOverlayView.AddObserver(this, new NSString("bounds"), NSKeyValueObservingOptions.New | NSKeyValueObservingOptions.Old , IntPtr.Zero);


public override void ObserveValue(NSString keyPath, NSObject ofObject, NSDictionary change, IntPtr context)
        {
            base.ObserveValue(keyPath, ofObject, change, context);

            if(ofObject == playerViewController.ContentOverlayView)
            {
                if(keyPath == "bounds")
                {
                    NSValue oldRect = change.ValueForKey(new NSString("NSKeyValueChangeOldKey")) as NSValue;
                    NSValue newRect = change.ValueForKey(new NSString("NSKeyValueChangeNewKey")) as NSValue;
                    CGRect oldBounds = oldRect.CGRectValue;
                    CGRect newBounds = newRect.CGRectValue;

                    bool wasFullscreen = CGRect.Equals(oldBounds, UIScreen.MainScreen.Bounds);
                    bool isFullscreen = CGRect.Equals(newBounds, UIScreen.MainScreen.Bounds);

                    if(isFullscreen && !wasFullscreen)
                    {
                        if(CGRect.Equals(oldBounds,new CGRect(0,0,newBounds.Size.Height, newBounds.Size.Width)))
                        {
                            Console.WriteLine("rotated fullscreen");
                        }
                        else
                        {
                            Console.WriteLine("entered fullscreen");
                        }
                    }
                    else if(!isFullscreen && wasFullscreen)
                    {
                        Console.WriteLine("exited fullscreen");
                    }
                }
            }
        }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47206231

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档