我在點擊全屏按鈕時在UIWebView中播放本地視頻時遇到了一些問題。iOS 6全屏本地視頻使用UIWebView和loadHTMLString
這是一款iPad應用程序,當我轉到有視頻的視圖並點擊播放按鈕時,它會播放正常,我可以跳過並暫停/播放。但是當談到點擊全屏時,它會將視頻拉伸到全屏,播放一秒鐘,全屏將會消失,而不是在其中放置視頻就是一個白色框。我已經在運行iOS 6的iPad 3rd Gen和運行iOS 6的iPad模擬器上測試了這一點,兩者都做同樣的事情。但是,在運行iOS 5的iPad 1st Gen和運行iOS 5的模擬器上,兩者都將全屏播放。
在iOS 6的iPad /模擬器,當我點擊的視頻播放,在調試區我看到以下內容:
2012-12-06 16:11:07.361 PICO[19131:11f03] [MPAVController] Autoplay: Enabling autoplay
2012-12-06 16:11:07.362 PICO[19131:11f03] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2012-12-06 16:11:07.362 PICO[19131:11f03] setting movie path: file:///Users/Nathan/Library/Application%20Support/iPhone%20Simulator/6.0/Applications/DB4C3A91-F148-417B-8319-4690F89E1382/PICO.app/30.20.mp4
2012-12-06 16:11:07.362 PICO[19131:11f03] [MPAVController] Autoplay: Enabling autoplay
2012-12-06 16:11:07.368 PICO[19131:11f03] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0
2012-12-06 16:11:07.437 PICO[19131:11f03] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
2012-12-06 16:11:07.447 PICO[19131:11f03] [MPAVController] Autoplay: Enabling autoplay
2012-12-06 16:11:07.448 PICO[19131:11f03] [MPAVController] Autoplay: _streamLikelyToKeepUp: 0 -> 1
,然後當我點擊全屏按鈕:
2012-12-06 16:12:39.918 PICO[19131:11f03] [MPAVController] Autoplay: Enabling autoplay
2012-12-06 16:12:40.168 PICO[19131:11f03] [MPAVController] Autoplay: Enabling autoplay
2012-12-06 16:12:40.178 PICO[19131:11f03] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
這裏是我的代碼嗎:
.H
@property (strong, nonatomic) IBOutlet UIWebView *videoView;
.M
[videoView loadHTMLString:@"<body style=\"margin:0px;\"><video src=\"30.20.mp4\" controls width=\"640\" height=\"360\"></video></body>" baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]]];
videoView.scrollView.scrollEnabled = NO;
所以你可以我只是用loadHTMLString與本地視頻源的視頻標籤加載看到。我在網上有一個很好的看,只是無法找到任何關於此。希望這只是一些簡單的事情!
您使用的UIWebView只播放視頻?爲什麼不是MPMoviePlayerController或MPMoviePlayerViewController? – lupatus
@lupatus因爲使用UIWebView,我可以在需要的尺寸位置放置我想要的尺寸,它將顯示視圖框和播放按鈕。當點擊該播放按鈕時,它將在640x360區域內播放,這是必要的,因爲它旁邊有所需的信息,並且還會提供全屏選項。我可以用上面的兩行代碼來完成所有這些。它只是起作用。我看了一下MPMoviePlayer,但它似乎沒有做那樣簡單,隨意去證明我錯了,儘管 – Nathan
我必須檢查它,很久很久以前我正在玩視頻播放器,但我認爲它也像幾行代碼。 – lupatus