iOS video streaming and storing on device afterwards

前端 未结 5 831
情书的邮戳
情书的邮戳 2020-12-23 17:27

So far I know how to stream a video and how to download it and afterwards stream it, but here\'s the tricky bit: streaming it once, storing it on the device and in the futur

5条回答
  •  感情败类
    2020-12-23 17:43

    It's quite easy to save the video. Do something similar to this:

    //Saving Movie
    NSMutableData *data = [[NSMutableData alloc] init];
    NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc] initForWritingWithMutableData:data];          
    [archiver encodeObject:*MovieObject* forKey:@"MovieObjectDataKey"];
    [archiver finishEncoding];
    [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"MovieObjectDefaultsDataKey"];
    [archiver release];
    [data release];
    
    //Retrieving movie 
    NSData *savedMovieData = [[NSUserDefaults standardUserDefaults] objectForKey:@"MovieObjectDefaultsDataKey"];
    if (savedMovieData != nil) {
        NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:savedMovieData];
        *MovieObject* = [[unarchiver decodeObjectForKey:@"MovieObjectDataKey"] retain];
        [unarchiver finishDecoding];
        [savedMovieData release];
        [unarchiver release];
    } else {
        //Download Stream of Your Movie
    }
    

    The only thing you really have to change there is * MovieObject *, once in each step.

提交回复
热议问题