使用 Expo EAS 構建時,影片 gif 在 Android 中有效,但影片 webp (awebp) 不支持。
為什么?
你如何讓 awebp 作業?
uj5u.com熱心網友回復:
為什么當影片 gif 起作用時它不起作用?
- React Native支持多種格式的影片影像,但它是可選的,需要內置。
- 默認情況下,Expo EAS 將它們全部構建在除了影片 webp 之外,因為...
默認情況下它是禁用的,因為 RN 在 iOS 上并不真正支持影片 webp。您必須使用外部庫才能使用它,例如快速影像。Expo 試圖統一 API,如果 iOS 和 Android 上的行為有很大不同,它會選擇適用于兩者的默認行為。
Cedric(世博會團隊成員)通過 Discord
如何啟用
- 創建一個EAS 配置插件。
- 將插件檔案添加到您的專案中。
- 在
pluginseas 組態檔的鍵中添加對該檔案的參考。
這是配置插件。
// withAnimatedWebp.js
const { createRunOncePlugin, withGradleProperties } = require('@expo/config-plugins');
const withAnimatedWebp = (config) => {
const itemToModify = {
type: 'property',
key: 'expo.webp.animated',
value: 'true',
};
return withGradleProperties(config, (config) => {
config.modResults = config.modResults.filter(
(item) => !(item.type === itemToModify.type && item.key === itemToModify.key)
);
config.modResults.push(itemToModify);
return config;
});
};
module.exports = createRunOncePlugin(withAnimatedWebp, 'animated-webp-support', '1.0.0');
# inside app.config.json
plugins: ['./eas_build_config_plugins/withAnimatedWebp'],
感謝@wodin在世博論壇上為我指明了正確的方向。
uj5u.com熱心網友回復:
我已經創造了一些世博配置,插件,其啟用影片iOS和Android(與作品WebP的支持世博會(一個基于你的作業)<Image />和<FastImage />。
小心,它正在使用expo的危險模組(修補本機檔案),請務必檢查之后一切是否仍然運行順利。expo prebuild --clean遇到問題記得觸發。
帶有更多檔案的要點
https://gist.github.com/Hirbod/07c6641970c9406ff35a7271dda1f01c
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/405733.html
標籤:
