简体   繁体   English

如何将视频放入 iOS 4.2 中的 iPhone 模拟器相机胶卷?

[英]How do I get video into the iPhone simulator camera roll in iOS 4.2?

I've tried the solution described here and here , namely copying a QuickTime movie to ~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/VID_0001.m4v , but this doesn't seem to do anything, and I'm guessing something's changed since iOS 3.2 to make it not work.我已经尝试了此处此处描述的解决方案,即将 QuickTime 电影复制到~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/VID_0001.m4v ,但这似乎没有任何作用,并且我猜自 iOS 3.2 以来发生了一些变化,使其无法正常工作。

Note that I'd very much prefer a solution that doesn't involve adding code to my app, unless that really is the only way to do it.请注意,我非常喜欢不涉及向我的应用程序添加代码的解决方案,除非这确实是唯一的方法。

ETA: I know that it's possible to include video files as a resource; ETA:我知道可以将视频文件作为资源包含在内; what I want is to add video files to the camera roll -- as can be done with photos by (for instance) saving images from Safari -- so I can test functionality that involves picking media files.我想要的是将视频文件添加到相机胶卷中——就像可以通过(例如)从 Safari 保存图像来处理照片一样——这样我就可以测试涉及选择媒体文件的功能。

Updated again: If somebody can definitively tell me it's not possible, with references, that would be helpful too.再次更新:如果有人可以明确地告诉我这是不可能的,并提供参考,那也会有帮助。

I found a way that seems to work in most versions of the simulator (confirmed for 6.1):我找到了一种似乎适用于大多数模拟器版本的方法(在 6.1 中得到确认):

  1. Start up the simulator and navigate to the photos app from the home screen.启动模拟器并从主屏幕导航到照片应用程序。
  2. Drag and drop an .m4v file from your file system onto the simulator window..m4v文件从文件系统拖放到模拟器窗口。 The video will now be playing in safari.该视频现在将在 safari 中播放。
  3. Click "done" in the upper left hand corner.点击左上角的“完成”。
  4. Click on the " share " button and select "save to camera roll"点击“ 分享”按钮并选择“保存到相机胶卷”

You're done!你完成了!

For XC6 simulators, you can search for the simulator directory with this command-line command:对于 XC6 模拟器,您可以使用以下命令行命令搜索模拟器目录:

For example, if you want to find the directory with the "5s" device:例如,如果要查找带有“5s”设备的目录:

grep -r -e "5s" --include="device.plist" ~/Library/Developer/CoreSimulator/Devices

Once you have the folder, you can navigate to:获得文件夹后,您可以导航到:

<your-sim>/data/Media/DCIM/100APPLE

and copy your files in there.并将您的文件复制到那里。 When you launch the simulator, you should open the Photos app and it should "restore" the metadata for the media.当您启动模拟器时,您应该打开照片应用程序,它应该“恢复”媒体的元数据。 If that's not the case, you can also remove the "Downloads" and "PhotoData" folders and relaunch the simulator.如果不是这种情况,您还可以删除“下载”和“照片数据”文件夹并重新启动模拟器。

In Xcode 10+ , you can just drag-and-drop the video(s) into the simulator.Xcode 10+ 中,您只需将视频拖放到模拟器中即可。 If the Photos app is not open already, it will open and show the videos right there alongside the built-in sample photos.如果照片应用程序尚未打开,它将打开并在内置示例照片旁边显示视频。

This is what I had to do for Xcode 6.3.1 / iOS 8:这就是我必须为 Xcode 6.3.1 / iOS 8 做的事情:

  • open Safari打开 Safari
  • enter the filepath to the m4v on your Mac's HD using the file:// protocol, eg file:///Users/brentd/Desktop/video.m4v .使用file://协议在 Mac 的 HD 上输入 m4v 的file://路径,例如file:///Users/brentd/Desktop/video.m4v
  • Click Done点击完成
  • Click the share button点击分享按钮
  • Choose "Save Video"选择“保存视频”

The video will now be in your camera roll.该视频现在将在您的相机胶卷中。

this does not work ( does not open safari ) if you have an app installed on the simulator which has document .ext handler , it open's that app instead of safari, so just simply这不起作用(不打开 safari)如果你在模拟器上安装了一个应用程序,它有文档 .ext 处理程序,它会打开那个应用程序而不是 safari,所以只是简单

  • open safari on the simulator在模拟器上打开 safari
  • drag a video file from your desktop and drop it on the simulator's safari从桌面拖动视频文件并将其放到模拟器的 safari 中
  • Click 'Done'点击“完成”
  • Click 'Share'点击“分享”
  • Select 'Save To Camera Roll'选择“保存到相机胶卷”

Have you seen the solution by Shizam, here:您是否在此处看到 Shizam 的解决方案:

iphone - How do I add videos to iPad simulator? iphone - 如何将视频添加到 iPad 模拟器?

It requires code, however.但是,它需要代码。

If you stick your MP4 file into the "Resources" group/folder in xcode the simulator will have access to it just like other local resources.如果您将 MP4 文件粘贴到 xcode 中的“资源”组/文件夹中,模拟器将可以像其他本地资源一样访问它。

Below is an example on devx that illustrates playing a movie file from the resources group.下面是 devx 上的一个示例,说明播放资源组中的电影文件。

devx Example devx 示例

I used the code solution in the end, but looking at the simulator folders afterwards, it's using a different naming strategy for the videos.我最后使用了代码解决方案,但后来查看模拟器文件夹,它对视频使用了不同的命名策略。

Maybe it will work if you save the file as:如果您将文件另存为:

~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/IMG_0001.M4V ~/Library/Application Support/iPhone Simulator/User/Media/DCIM/100APPLE/IMG_0001.M4V

Sign in to your iCloud account from the simulator.从模拟器登录您的 iCloud 帐户。 Sync your phone photos and videos with iCloud.将您的手机照片和视频与 iCloud 同步。 They will simply appear.他们只会出现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM