iOS 上的 Expo 无法再保存视频
Unable to save video anymore with Expo on iOS
我有一个 Expo 应用程序 (iOS/Android),允许用户录制短视频(和图片)并分享它们(除其他外)。它在两个操作系统上都运行良好一段时间,但最近它停止在 iOS 上运行(Android 仍然运行良好)。拍照在两种设备上都正常。
以下是尝试保存上述视频时使用的代码:
const recordPromise = this.camera.recordAsync({
maxDuration: 5,
quality: Camera.Constants.VideoQuality["720p"],
});
const videoData = await recordPromise;
let asset = await MediaLibrary.createAssetAsync(videoData.uri);
在 createAssetAsync() 上引发了以下错误:
[Unhandled promise rejection: Error: Asset couldn't be saved to photo library]
记录本身似乎没问题(uri已匿名):
Object {
"uri": "file:///var/mobile/Containers/Data/Application/00000000-0000-0000-0000-000000000000/Library/Caches/ExponentExperienceData/%2540app%252Fapp/Camera/0F46F276-DCBE-4999-A3E0-0E10955467AF.mov",
}
在 componentDidMount 中请求权限并已被授予:
const permissionCamera = await Camera.requestPermissionsAsync();
const permissionLibrary = await MediaLibrary.requestPermissionsAsync();
const permissionMicro = await Camera.requestMicrophonePermissionsAsync();
在设置中检查Expo Go的权限时,它们是正确允许的。
MediaLibrary.getPermissionsAsync(); returns :
{
"accessPrivileges": "all",
"canAskAgain": true,
"expires": "never",
"granted": true,
"status": "granted",
}
相同的代码在几周前运行良好,并且在 Android 上仍然运行良好。我认为这是一个与 Apple 相关的更改,但在文档或互联网上没有找到。
Expo CLI 版本为 4.10.1,SDK 42,iOS 为 14.8,但该问题已在多个不同的设备上出现。
Expo Go 是最新的,为了以防万一,我什至卸载并重新安装了 Expo Go。没有在 testflight 中尝试过那个失败的版本(在我们再次发布任何东西之前需要用 Apple 处理一些帐户内容),但无论如何我需要它在 expo go 中再次工作。
几乎 120 天以来,该文件中的任何内容都没有更改。
我制作了一个重现相同问题的纯应用程序。代码可以在这里找到:https://github.com/sebastien-f/expo-test-video
问题是由 camera.recordAsync() 创建的,几乎一开始就停止。只有在使用 quality 道具时才会发生。现在,我已经删除了参数并在 Github 上打开了一个问题:https://github.com/expo/expo/issues/14432
我有一个 Expo 应用程序 (iOS/Android),允许用户录制短视频(和图片)并分享它们(除其他外)。它在两个操作系统上都运行良好一段时间,但最近它停止在 iOS 上运行(Android 仍然运行良好)。拍照在两种设备上都正常。
以下是尝试保存上述视频时使用的代码:
const recordPromise = this.camera.recordAsync({
maxDuration: 5,
quality: Camera.Constants.VideoQuality["720p"],
});
const videoData = await recordPromise;
let asset = await MediaLibrary.createAssetAsync(videoData.uri);
在 createAssetAsync() 上引发了以下错误:
[Unhandled promise rejection: Error: Asset couldn't be saved to photo library]
记录本身似乎没问题(uri已匿名):
Object {
"uri": "file:///var/mobile/Containers/Data/Application/00000000-0000-0000-0000-000000000000/Library/Caches/ExponentExperienceData/%2540app%252Fapp/Camera/0F46F276-DCBE-4999-A3E0-0E10955467AF.mov",
}
在 componentDidMount 中请求权限并已被授予:
const permissionCamera = await Camera.requestPermissionsAsync();
const permissionLibrary = await MediaLibrary.requestPermissionsAsync();
const permissionMicro = await Camera.requestMicrophonePermissionsAsync();
在设置中检查Expo Go的权限时,它们是正确允许的。
MediaLibrary.getPermissionsAsync(); returns :
{
"accessPrivileges": "all",
"canAskAgain": true,
"expires": "never",
"granted": true,
"status": "granted",
}
相同的代码在几周前运行良好,并且在 Android 上仍然运行良好。我认为这是一个与 Apple 相关的更改,但在文档或互联网上没有找到。
Expo CLI 版本为 4.10.1,SDK 42,iOS 为 14.8,但该问题已在多个不同的设备上出现。
Expo Go 是最新的,为了以防万一,我什至卸载并重新安装了 Expo Go。没有在 testflight 中尝试过那个失败的版本(在我们再次发布任何东西之前需要用 Apple 处理一些帐户内容),但无论如何我需要它在 expo go 中再次工作。
几乎 120 天以来,该文件中的任何内容都没有更改。
我制作了一个重现相同问题的纯应用程序。代码可以在这里找到:https://github.com/sebastien-f/expo-test-video
问题是由 camera.recordAsync() 创建的,几乎一开始就停止。只有在使用 quality 道具时才会发生。现在,我已经删除了参数并在 Github 上打开了一个问题:https://github.com/expo/expo/issues/14432