2012-06-13 65 views
0

在我的iPhone應用程序中,我想以小視圖播放視頻。iphone應用程序:僅在小視圖中播放視頻

視頻應該開始自動播放,並且應該隱藏播放暫停和全屏的按鈕。

enter image description here

我怎麼能做到這一點?

請幫助和建議。

感謝

+0

這是一個UIWebView內?如果是的話,那些其他人的答案可能不是你想要的 – Gruntcakes

+0

@馬丁你是對的。這適用於mpmovieplayercontroller。爲網絡視圖我不知道我怎麼能這樣做? – ios

+0

因爲它在UIWebView中,我想知道如果你想播放視頻作爲網頁視圖加載的HTML的一部分,在這種情況下,你可以嵌入視頻輕鬆使用HTML5視頻標籤播放內嵌,指定大小等。 – Gruntcakes

回答

0

你會做什麼手動設置爲MPMoviePlayerController的觀點框架,以及控制樣式設置爲MPMovieControlStyleNone。就像下面這樣..

.... 
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]]; 
[player setControlStyle:MPMovieControlStyleNone]; 

//this is where you create your `embedded` view size 
player.view.frame = CGRectMake(0, 0, 200, 300); 

[self.view addSubview:player.view]; 
.... 
0
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] init]; 
[player prepareToPlay]; 
player.shouldAutoplay = NO; 
player.allowsAirPlay = YES; 
player.scalingMode = MPMovieScalingModeAspectFit; 
[player.view setFrame:CGRectMake(0,0,300,320)]; 
[viewPlayer addSubview:player.view]; 

    self.moviePlayer = player;//declare MPMoviePlayerController class object globaly for play and push the vedio if you want to add this functionality 

希望,這幫助你.... :)