Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.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 使用UIWebView和loadHTMLString的iOS 6全屏本地视频_Objective C_Ios_Uiwebview_Ios6 - Fatal编程技术网

Objective c 使用UIWebView和loadHTMLString的iOS 6全屏本地视频

Objective c 使用UIWebView和loadHTMLString的iOS 6全屏本地视频,objective-c,ios,uiwebview,ios6,Objective C,Ios,Uiwebview,Ios6,单击全屏按钮时,在UIWebView中播放本地视频有点问题 这是一个iPad应用程序,当我进入有视频的视图,点击播放按钮,它就会播放,我可以跳过并暂停/播放。但当点击全屏时,它会将视频拉伸到全屏,播放一秒钟,全屏将消失,而不是在它的位置显示视频只是一个白色的框。我已经在运行iOS 6的第三代iPad和运行iOS 6的iPad模拟器上进行了测试,两者都做了同样的测试。不过,在运行iOS 5的iPad第1代和运行iOS 5的模拟器上,两者都可以全屏播放 在iOS 6 iPad/simulator上,

单击全屏按钮时,在UIWebView中播放本地视频有点问题

这是一个iPad应用程序,当我进入有视频的视图,点击播放按钮,它就会播放,我可以跳过并暂停/播放。但当点击全屏时,它会将视频拉伸到全屏,播放一秒钟,全屏将消失,而不是在它的位置显示视频只是一个白色的框。我已经在运行iOS 6的第三代iPad和运行iOS 6的iPad模拟器上进行了测试,两者都做了同样的测试。不过,在运行iOS 5的iPad第1代和运行iOS 5的模拟器上,两者都可以全屏播放

在iOS 6 iPad/simulator上,当我单击视频播放时,在调试区域我看到以下内容:

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

m

[videoView loadHTMLString:@“baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]bundlePath]];
videoView.scrollView.scrollEnabled=否;

如你所见,我只是使用loadHTMLString加载本地视频的视频标签。我在网上看了一眼,就是找不到这方面的任何东西。希望这只是简单的事情

好吧,我就是这样修好的

添加MediaPlayer框架。目标>构建阶段>链接二进制..>+按钮<开始键入MediaPlayer

然后使用下面的代码

YourClass.h
#import <MediaPlayer/MediaPlayer.h>
@interface YourClass : UIViewController
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer; //creating the property is a must else it will show a black box instead of your video and will not play

YourClass.m
@synthesize moviePlayer; 
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"myVideoFile" ofType:@"mp4"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
moviePlayer.view.frame = CGRectMake(73, 203, 640, 360); //position you want the player and it's size
[self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer setShouldAutoplay:NO]; //autoplays by default
YourClass.h
#进口
@接口类:UIViewController
@属性(强,非原子)MPMoviePlayerController*moviePlayer//创建属性是必须的,否则它将显示一个黑匣子而不是您的视频,并且不会播放
你的班级
@综合电影演员;
NSString*moviePath=[[NSBundle mainBundle]路径用于资源:@“mp4”类型的“myVideoFile”;
moviePlayer=[[MPMoviePlayerController alloc]initWithContentURL:[NSURL文件URL WithPath:moviePath]];
moviePlayer.view.frame=CGRectMake(73203640360)//你想要球员的位置和大小
[self.view addSubview:moviePlayer.view];
[电影播放器准备播放];
[电影播放器设置应自动播放:否]//默认情况下自动播放

在iOS 5.1和6中适用于我您使用UIWebView只是为了播放视频?为什么不使用MPMoviePlayerController或mpmovieplayervicewcontroller?@lupatus,因为使用UIWebView,我可以按我想要的大小定位,它将显示视图的框架和播放按钮。当点击该播放按钮时,它将在640x360区域内播放,这是必要的,因为它旁边有所需的信息,它还将提供全屏选项。我可以用上面的两行代码来完成这一切。而且它很有效。我看了一下MPMoviePlayer,但它似乎没有那么简单,请随意证明我错了,尽管我必须检查一下,我很久以前就在玩视频播放器,但我认为它也像是几行代码。有解决方案吗?我也被同样的问题困扰着。嗨@NikitaP,如果你还被困扰着,看看我的答案
[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;
YourClass.h
#import <MediaPlayer/MediaPlayer.h>
@interface YourClass : UIViewController
@property (strong, nonatomic) MPMoviePlayerController *moviePlayer; //creating the property is a must else it will show a black box instead of your video and will not play

YourClass.m
@synthesize moviePlayer; 
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"myVideoFile" ofType:@"mp4"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
moviePlayer.view.frame = CGRectMake(73, 203, 640, 360); //position you want the player and it's size
[self.view addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
[moviePlayer setShouldAutoplay:NO]; //autoplays by default