Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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
Ios 无法在web视图中播放单个视频_Ios - Fatal编程技术网

Ios 无法在web视图中播放单个视频

Ios 无法在web视图中播放单个视频,ios,Ios,在我的应用程序中,我需要在UIWebView中播放单个视频,我可以在UIWebView中播放播放列表 获取视频的链接是: 这是我的密码: - (void)viewDidLoad { [super viewDidLoad]; NSString *videoURL=[self getYTUrlStr:stringURL]; NSURL *url=[NSURL URLWithString:videoURL]; [self.web loadRequest:[NSURL

在我的应用程序中,我需要在
UIWebView
中播放单个视频,我可以在
UIWebView
中播放播放列表

获取视频的链接是:

这是我的密码:

- (void)viewDidLoad
{
    [super viewDidLoad];

    NSString *videoURL=[self getYTUrlStr:stringURL];
    NSURL *url=[NSURL URLWithString:videoURL];
    [self.web loadRequest:[NSURLRequest requestWithURL:url]];


    NSString *videoURL=[self getYTUrlStr:stringURL];
    - (NSString*)getYTUrlStr:(NSString*)url
    {
    if (url == nil)
        return nil;

    NSString *retVal = [url stringByReplacingOccurrencesOfString:@"watch?v=" withString:@"v/"];

    NSRange pos=[retVal rangeOfString:@"version"];
    if(pos.location == NSNotFound)
    {
        retVal = [retVal stringByAppendingString:@"?version=3&hl=en_EN"];
    }
    return retVal;
    }

需要修改链接如下

videoURL = [videoURL stringByReplacingOccurrencesOfString:@"http://www.youtube.com/v/" withString:@"http://www.youtube.com/embed/"];
videoURL=[videoURL stringByReplacingOccurrencesOfString:@"?version=3&hl=en_EN" withString:@"?feature=player_detailpag"];
videoURL = [videoURL stringByReplacingOccurrencesOfString:@"?version=3&f=user_uploads&app=youtube_gdata" withString:@"?feature=player_detailpage"];
然后将提供给实例方法的UIWebView实例方法loadRequest作为NSURLRequest