How to add video to iphone simulator

前端 未结 8 1434
情书的邮戳
情书的邮戳 2020-12-28 15:43

Can anyone tell me how to add video the iPhone simulator so that I can test some apps I am working on? Thanks in advance!

相关标签:
8条回答
  • 2020-12-28 15:56

    You can add Your file by adding these 2 lines of code in appdelegate.m

    NSString *path = [[NSBundle mainBundle] pathForResource:@"sample_iTunes" ofType:@"mov"];
    UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);`
    
    0 讨论(0)
  • 2020-12-28 15:56

    go to following path and past video

    /Users/"username"/Library/Developer/CoreSimulator/Devices/11BFF1F0-2A2B-409A-9727-3267D71E10D4/data/Media

    0 讨论(0)
  • 2020-12-28 16:00

    If you're asking how to add video to your app the simple way to show video using MediaPlayer.h lib.

    // fileURL is a NSURL made from file path in app bundle
    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL: fileURL];
    [[mp view] setFrame:CGRectMake(0,0,100,100)];
    [mp play];
    

    You should set many parameters for mp object: scaling, controls, etc.

    0 讨论(0)
  • 2020-12-28 16:16

    okey, try this:

    - (void) downloadVideo {
    NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://sepwww.stanford.edu/sep/jon/trash/poolwaves.mov"]];
    

    You can change the temp.mov to temp.m4v to save the vid in m4v.

    NSString *tempPath = [NSString stringWithFormat:@"%@/temp.mov", NSTemporaryDirectory()];
    [imageData writeToFile:tempPath atomically:NO];
    UISaveVideoAtPathToSavedPhotosAlbum (tempPath, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
    }
    
    
    - (void) video: (NSString *) videoPath
    didFinishSavingWithError: (NSError *) error
       contextInfo: (void *) contextInfo {
        NSLog(@"Finished saving video with error: %@", error);
    }
    

    if you change the url to your moviefile, this should work really well... the movies are saved in this directory: /Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM but you are right, if i copy a file to it, it won't show up in the simulator

    greets

    0 讨论(0)
  • 2020-12-28 16:17

    It's very simple you just drag any .MOV file to your simulator. Now it will be opened in Safari browser. At top left corner there is a 'Done' button. You just have to press it after this you can press Share button then just choose the option save video and it's done. Now play it in your app. :)

    0 讨论(0)
  • 2020-12-28 16:17

    You need to add video in your application bundle itself. Later you can copy that to the documents directory.

    0 讨论(0)
提交回复
热议问题