我試圖在視圖加載時播放一個簡單的mp4文件全屏。這裏是代碼:iOS無法播放視頻
我沒有得到一個視頻,但我知道viewDidLoad被調用,並且存在一個視圖。
//
// FirstViewController.m
// WSTR Finale
//
// Created by Chris Muench on 10/6/14.
// Copyright (c) 2014 World Series of Team Roping. All rights reserved.
//
#import "WatchLiveViewController.h"
#import <MediaPlayer/MediaPlayer.h>
@interface WatchLiveViewController()
@end
@implementation WatchLiveViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSURL *movieURL = [NSURL URLWithString:@"http://download.wavetlan.com/SVV/Media/HTTP/H264/Talkinghead_Media/H264_test1_Talkinghead_mp4_480x360.mp4"];
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayer.view setFrame:backgroundWindow.frame];
[backgroundWindow addSubview:moviePlayer.view];
[moviePlayer play];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
是否沒有變換工作?您應該考慮使用backgroundWindow.bounds而不是.frame來避免重複偏移。 – 2014-10-07 15:56:11
我確定在將實際視圖控制器放入導航堆棧之前,您已經知道「框架」和「邊界」屬性是未定義的(甚至可能是CGRectNull) - 並且調用了「-viewDidLoad」方法絕對_before_。 – holex 2014-10-07 16:02:57
我試圖改變它viewDidAppear現在我只是得到一個大的黑色屏幕沒有任何視頻控制器或視頻 – 2014-10-07 16:05:11