문제

I just try to play an apple's HLS sample stream. My code is very simple:

- (IBAction)playHLS:(id)sender {
    NSString* str = @"https:​/​/​devimages.apple.com.edgekey.net/​resources/​http-streaming/​examples/​bipbop_16x9/​bipbop_16x9_variant.m3u8";
    NSURL *url = [[NSURL alloc] initWithString:str];


    MPMoviePlayerViewController *theMovie = [[MPMoviePlayerViewController alloc]
                                             initWithContentURL: url];

    [self presentMoviePlayerViewControllerAnimated:theMovie];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
}

The debug reveals that url is not initialized properly due to <invalid CFStringRef>

What did i miss here?

도움이 되었습니까?

해결책

The string has several Unicode zero-width-space characters in it, after each the : and / characters.

You can see them if you paste it into this online UTF-8 decoder, for instance. They're Unicode character 0x200B.

다른 팁

It's weird!

The problem is that i copy&pasted url from browser. The code works correctly after I type in the code.

Still don't know why, hope it helps somebody who encounter the same problem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top