Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top