Search code examples
iosm3u8

I want to get different video streams in iOS player


I'm using M3U8Parser, but i'm getting exception while execution.

NSString *plainString = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error];
infolist = [M3U8Parser m3u8SegmentInfoListFromPlanString:plainString];

After infolist,i'm getting exception.

reason: '-[__NSCFString substringWithRange:]: Range {10, 9223372036854775797} out of bounds; string length 36'

Pls help!


Solution

  • You need to make some changes in NSString+m3u8.m:

    if(NSNotFound != bandwidthRange.location) {
            NSString *value;
        // issue fixed
                    if (commaRange.length == 0)
                    {
                        value = [substring substringFromIndex:10];
    
                    }
                    else
                    {
                        value = [substring substringWithRange:NSMakeRange(bandwidthRange.length+1, commaRange.location - (bandwidthRange.length+1))];
                    }
            [params setValue:value forKey:keyM3U8SegmentBandwidth];
        }
    

    For now i have hard coded the value, you can modify for your requirement.