2016-09-29 74 views
1

我使用YTPlayerView Youtube API來支持我的應用中的視頻。適用於iOS的Youtube API不再支持自iOS 10以來的景觀?

在iOS10發佈之前,我的應用程序正在將視頻正確切換爲風景,當視頻播放全屏並旋轉設備時。

由於我升級到iOS10,視頻不再隨設備一起旋轉,這可以在模擬器(與iOS 9一起使用,不再使用iOS 10)中再現。

我的應用程序只支持肖像模式,但是我可以在全屏播放時將全屏視頻切換到風景。

任何提示? 感謝

+0

我認爲只有Google員工才能回答您。我沒有看到有關您可以在[Data API](https://developers.google.com/youtube/v3/revision_history)和[IOS Helper](https://開發人員)中看到的問題的任何更新版本。 google.com/youtube/v3/guides/ios_youtube_helper#best-practices-and-limitations)。如果您認爲這是一個錯誤,那麼請嘗試[提交一張票](https://code.google.com/p/gdata-issues/issues/list?q=label:APi-YouTube)瞭解此問題。 – KENdi

回答

1

由於定向模式在iOS的10的處理方式則有以下選項:

「政治」 -correct解決方案

1)讓你的應用在所有的在info.plist中

2)方向性模式不允許景觀其他地方

的哈克解決方案

每次旋轉手機時,都會調用您的AppDelegate,以瞭解特定窗口的支持方向。因此,如果您可以檢測到「當前窗口」內的視圖控制器是youtube視頻控制器,那麼您可以返回所有方向,否則返回portret。

func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { 
    guard let topController = window?.topController() else { 
     return application.supportedInterfaceOrientations(for: window) 
    } 

    let className = NSStringFromClass(type(of: topController)) 
    let hackyViewControllers = ["avfullscreenviewcontroller"] 

    if hackyViewControllers.contains(className.lowercased()) { 
     return .allButUpsideDown 
    } else { 
     return .portrait 
    } 
    } 

**,你可以看到我們檢查AVFullScreenViewController這正是UIViewController子類負責全屏顯示YouTube視頻。