我有一個iOS應用程序,我試圖使用MPMoviePlayerController
來顯示視頻。 該代碼非常簡單,適用於所有iOS版本大於6.0的設備。iOS 8視頻進度條不可見
但問題是在iOS 8和8.1上,視頻的進度條不可見,如下圖所示。
我不明白爲什麼這種情況正在發生,或者這是iOS 8的錯誤。
請建議。 在此先感謝。
我有一個iOS應用程序,我試圖使用MPMoviePlayerController
來顯示視頻。 該代碼非常簡單,適用於所有iOS版本大於6.0的設備。iOS 8視頻進度條不可見
但問題是在iOS 8和8.1上,視頻的進度條不可見,如下圖所示。
我不明白爲什麼這種情況正在發生,或者這是iOS 8的錯誤。
請建議。 在此先感謝。
我在我的應用程序,它支持多種版本的IOS有這個問題太多,但這個問題確實只在iOS上看到8
我的代碼將切換MPMoviePlayerController
的controlStyle
MPMovieControlStyleEmbedded
和MPMovieControlStyleNone
之間,這是觸發使用UIDeviceOrientationDidChangeNotification
。我不得不承認,我編程旋轉我的播放器,我不旋轉應用程序;這可能是這個問題的根源。我以縱向顯示控件,並將它們隱藏在橫向上。
我明顯地通過兩個步驟解決它。我沒有在一個簡單的應用程序中隔離這個問題,所以如果解決方案對每個人都不準確,我很抱歉。
首先,髒的部分,也許沒有必要爲大家誰遇到此問題,我分析了一些玩家子視圖的MPVideoPlaybackOverlayView
視圖照顧,以迫使其知名度或不可見。
// Helps to hide or show the controls over the player
// The reason of this method is we are programmatically rotating the player view, while not rotating the application
// On latest iOS, this leads to misbehavior that we have to take into account
-(void)showMPMoviePlayerControls:(BOOL)show
{
self.player.controlStyle = (show ? MPMovieControlStyleEmbedded : MPMovieControlStyleNone);
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8"))
{
// Workaround to avoid persistence of empty control bar
for(UIView *subView in self.player.backgroundView.superview.superview.subviews)
{
if ([subView isKindOfClass:NSClassFromString(@"MPVideoPlaybackOverlayView")]) {
subView.backgroundColor = [UIColor clearColor];
subView.alpha = (show ? 1.0 : 0.0);
subView.hidden = (show ? NO : YES);
}
}
}
}
但這還不夠。可能是因爲人像模式具有多個觸發通知的方向(UIDeviceOrientationPortrait
,UIDeviceOrientationFaceUp
,...),因此控制方式更改請求。
所以第二步我修復是處理的事實,這是沒有必要改變MPMoviePlayerController
的controlStyle
如果我們已經在正確的屏幕方向。 在我的情況下,解決辦法是驗證狀態欄被隱藏,因爲我把它藏在景觀:
// Set embedded controls only when there is a transition to portrait, i.e. if status bar was hidden
if ([[UIApplication sharedApplication] isStatusBarHidden]) {
[self showMPMoviePlayerControls:YES];
// and we show the status bar here
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];
}
也許這裏的關鍵是,我們不應該設置controlStyle
如果它已經被設置爲想要的價值。
由於這解決了我的問題,我停止了我的調查。無論如何,我想在大多數情況下它可能更簡單。當然,這與controlStyle
在錯誤的時間更改或更改,但已經處於通緝狀態有關。
@Johann ....謝謝你的回覆....但在我的情況下,我發現它是重新繪製視圖的問題...所以我只是加載一個空白的視圖控制器之前播放視頻0.5秒,並刪除它......並且事情按預期工作。 – Avin