如何将视频添加到 iPhone 模拟器

发布于 2024-11-15 20:44:57 字数 56 浏览 2 评论 0原文

谁能告诉我如何向 iPhone 模拟器添加视频,以便我可以测试我正在开发的一些应用程序?提前致谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

习惯成性 2024-11-22 20:44:57

这非常简单,您只需将任何 .MOV 文件拖到模拟器中即可。现在它将在 Safari 浏览器中打开。左上角有一个“完成”按钮。您只需按一下即可
您可以按“共享”按钮,然后只需选择“保存视频”选项即可完成。现在在您的应用程序中播放它。 :)

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. :)

黑寡妇 2024-11-22 20:44:57

我对图像做了同样的操作,将视频拖放到 iOS 模拟器上,不仅仅是照片的应用程序,而且在拖放时任何应用程序都可以在其上运行。

第 1 步:拖放。

在此处输入图像描述

第 2 步:打开 iOS 模拟器启动 safari 播放视频文件。

在此处输入图片描述

第 3 步:点击分享图标以获取“保存视频”选项在操作列表中。

在此处输入图像描述

但是多次点击“保存视频”操作却没有任何反应,没有任何内容被添加到相册中。有什么想法吗?甚至尝试将视频文件复制粘贴到模拟器的 DCIM 路径中。

I did the same as you do with images, drag dropped the video onto the iOS simulator not just photo's app but any app can be running on it at the time you drag drop.

Step 1: Drag drop.

enter image description here

Step 2: iOS simulator opens up safari to play the video file.

enter image description here

Step 3: Click on the share icon to get the Save Video option in the action's list.

enter image description here

But clicking on Save Video action for so many times nothing happens and nothing gets added to the albums. Any ideas? Even tried copy pasting the video file to the simulator's DCIM path.

我喜欢麦丽素 2024-11-22 20:44:57

好吧,试试这个:

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

您可以将 temp.mov 更改为 temp.m4v 以将 vid 保存为 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);
}

如果你改变你的电影文件的网址,这应该工作得很好......
电影保存在此目录中:/Library/Application Support/iPhone Simulator/4.3.2/Media/DCIM
但你是对的,如果我将文件复制到其中,它不会显示在模拟器的

问候语中

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

橘虞初梦 2024-11-22 20:44:57

简短回答:

  1. 将您的视频文件放入 ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE/ 中,并可能删除 Media 中的 PhotoData 文件。

长答案:

  1. 确保iPhone 支持您的电影文件类型。我使用了 .mov
  2. 打开库。 (您的用户名/图书馆)如果找不到
    文件,它是隐藏的。 使其可见或用户终端。
  3. 导航至 ~/Library/Application Support/iPhone Simulator/
    如果您有多个 iOS 模拟器,请选择您正在开发的一个
    目前来说。 (我有 5.0、5.1、6.0 和 6.1)
  4. 导航到 ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE/ 并放入您的视频文件。如果 100APPLE 目录不存在,请创建它。
  5. 有时你有
    删除导航到 ~/Library/Application 中的 PhotoData 文件
    Support/iPhone Simulator/6.1/Media/ 强制模拟器
    识别新文件,因为您没有通过正常方式添加它。

Xcode 4.6.3 和 MacOS 10.8.4 仅供参考。还没有在 Xcode 5 上尝试过。

Short answer:

  1. Drop your video file into ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE/ and maybe delete the PhotoData file in Media.

Long Answer:

  1. Make sure your movie file type is supported on the iPhone. I used a .mov
  2. Open the Library. (YourUserName/Library) If you can't find
    the file, it is hidden. Make it visible or user Terminal.
  3. Navigate to ~/Library/Application Support/iPhone Simulator/
    If you have multiple iOS Simulators pick the one your are developing
    for currently. (I had 5.0, 5.1, 6.0 and 6.1)
  4. Navigate to ~/Library/Application Support/iPhone Simulator/6.1/Media/DCIM/100APPLE/ and drop in your video file. If the 100APPLE directory doesn't exist, create it.
  5. Sometimes you have
    to delete the PhotoData file in Navigate to ~/Library/Application
    Support/iPhone Simulator/6.1/Media/ to force the Simulator to
    recognize the new file since you didn't add it through normal means.

Xcode 4.6.3 and MacOS 10.8.4 fyi. Haven't tried on Xcode 5.

小清晰的声音 2024-11-22 20:44:57

您可以通过在 appdelegate.m 中添加这两行代码来添加您的文件

NSString *path = [[NSBundle mainBundle] pathForResource:@"sample_iTunes" ofType:@"mov"];
UISaveVideoAtPathToSavedPhotosAlbum(path, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);`

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);`
猫性小仙女 2024-11-22 20:44:57

对于 2022 年,如果您尝试直接从“下载”文件夹导入 .mov 文件,模拟器会给出模糊错误(PHPhotosErrorDomain 错误 -1)。要解决此问题,请将视频移动到根 /~ 目录并将其拖到模拟器中。

XCode 版本 - 13.2
模拟器 iOS 版本 - 15.2

For 2022, if you try to import a .mov file directly from the Downloads folder the simulator gives a vague error (PHPhotosErrorDomain error -1). To solve this move the video into your root /~ directory and drag it into the simulator.

XCode Version - 13.2
Simulator iOS Version - 15.2

隔岸观火 2024-11-22 20:44:57

转到以下路径和过去的视频

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

go to following path and past video

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

尘曦 2024-11-22 20:44:57

2024 从你的Mac上进行屏幕录制,然后将其拖放到模拟器中,它将显示在模拟器的照片应用程序下

2024 make a screen recording from your mac, and then drag and drop it into the simulator, it will be shown under the Photo app of the simulator

橙味迷妹 2024-11-22 20:44:57

如果您询问如何将视频添加到您的应用程序中,这是使用 MediaPlayer.h 库显示视频的简单方法。

// 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];

您应该为 mp 对象设置许多参数:缩放、控件等。

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.

等风来 2024-11-22 20:44:57

您需要在应用程序包本身中添加视频。稍后您可以将其复制到文档目录中。

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

尐偏执 2024-11-22 20:44:57

已经有一段时间了......拖放不知何故对我来说不适用于视频文件(对于 .mov 和 .mp4)。所以我采用了答案之一中的 obj-c 代码

let path = Bundle.main.path(forResource: "Video", ofType: "mov")!
UISaveVideoAtPathToSavedPhotosAlbum(path, nil, nil, nil)

It's been a while... Drag and drop somehow didn't work for me with video file (for both .mov and .mp4). So I adopted obj-c code from one of the answers

let path = Bundle.main.path(forResource: "Video", ofType: "mov")!
UISaveVideoAtPathToSavedPhotosAlbum(path, nil, nil, nil)
非要怀念 2024-11-22 20:44:57

打开 safari 浏览器并在模拟器中下载视频

https://www.sample-videos.com/< /a>

Open safari browser and download the video in simulator

https://www.sample-videos.com/

灯角 2024-11-22 20:44:57

2022 年,只需将视频(例如 Mac 上的屏幕录制)拖放到 iPhone 模拟器中,它就会出现在“照片”中

In 2022, just drag and drop a video (screen recording on your mac for example) to the iphone simulator and it will be there in the Photos

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文