Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c MPMoviePlayerController的大小_Objective C - Fatal编程技术网

Objective c MPMoviePlayerController的大小

Objective c MPMoviePlayerController的大小,objective-c,Objective C,如何更改MPMoviePlayerController的大小? 我不想让它全屏播放,我只想看到视频播放的部分视图。我找了很多,但找不到好答案 谢谢尝试使用您的尺寸初始化播放器,然后禁用控件: -(void) configurePlayer { self.moviePlayer = [[MPMoviePlayerController alloc] init]; [self.moviePlayer setControlStyle:MPMovieControlStyleNone]; self.m

如何更改MPMoviePlayerController的大小? 我不想让它全屏播放,我只想看到视频播放的部分视图。我找了很多,但找不到好答案


谢谢

尝试使用您的尺寸初始化播放器,然后禁用控件:

-(void) configurePlayer {

self.moviePlayer = [[MPMoviePlayerController alloc] init];

[self.moviePlayer setControlStyle:MPMovieControlStyleNone];

self.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;

[self.moviePlayer setMovieSourceType:(MPMovieSourceTypeStreaming)];

CGRect frame = CGRectMake(yourX, yourY, yourWidth, yourHeight);

[self.moviePlayer.view setFrame:frame];  // player's frame must match parent's

[self.view addSubview: self.moviePlayer.view];

[self.view bringSubviewToFront:self.moviePlayer.view];

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(metadataUpdate:)
                                             name:MPMoviePlayerPlaybackStateDidChangeNotification
                                           object:nil]; 
 }
对于游戏,请使用此方法

-(void) playStream {
NSURL *url = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
[self.moviePlayer setContentURL:url];
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];   
}
试试这个样品, 导入头文件中的
#导入
,并在项目中包含MediaPlayer框架

    - (IBAction)testVideoAction:(id)sender {
    NSURL *movieURL = [NSURL URLWithString:@"http://www.tools4movies.com/dvd_catalyst_profile_samples/Harold%20Kumar%203%20Christmas%20bionic.mp4"];
    MPMoviePlayerViewController *movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
        movieController.view.frame = CGRectMake(10, 10, 300, 300);
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
    [view addSubview:movieController.view];    
    [self.view addSubview:view];       
    [movieController.moviePlayer play];
}

谢谢,它工作了,但是视频没有播放,mpmovieplayercontroller是黑色的。首先,您必须配置播放器,然后使用-(void)播放流方法。请提供代码示例。你有没有写过@property(非原子,强)MPMoviePlayer*moviePlayer@syntesize moviePlayer=moviePlayer?