在使用Cordova插件时如何向Crosswalk添加媒体编解码器支持? [英] How do I add media codecs support to Crosswalk while using the Cordova plug-in?
问题描述
我正在构建一个PhoneGap应用,该应用需要播放AAC音频。使用本机 WebView
可以很好地工作,但是我想在针对API 16-20的构建中使用Crosswalk,因为我的应用程序中的某些CSS功能在Android上根本无法使用4.x。
I'm building a PhoneGap app which needs to play AAC audio. It works well using the native WebView
, but I would like to use Crosswalk on a build targeting APIs 16-20 because some CSS features in my app do not work at all on Android 4.x.
当我复制项目以添加Crosswalk Lite时,可以看到该应用程序可以正常运行,除了< audio>
元素指向AAC文件。这是因为默认情况下,Crosswalk不附带专有编解码器。
When I make a copy of the project to add Crosswalk Lite, I can see that the app works except for the <audio>
element pointing to a AAC file. This is because Crosswalk does not ship with proprietary codecs by default.
链接的页面上说:
构建人行横道使用这些编解码器,开发人员必须在打开必须接受EULA开关的情况下运行构建
:
To build Crosswalk with these codecs, a developer must run the build with the "must accept a EULA" switch turned on:
$ xwalk/gyp_xwalk -Dmediacodecs_EULA=1
然后构建Crosswalk。
中的 ffmpegsumo.dll 或 libffmpegsumo.so 会在构建输出目录中包含专有编解码器。
Then build Crosswalk. The ffmpegsumo.dll or libffmpegsumo.so in the build output directory will contain the proprietary codecs.
有关更多详细信息,请参见人行横道施工说明。
Refer to Crosswalk Build Instruction for more details.
但是,我使用建议的插件添加了Crosswalk,因此我得到了没有专有编解码器的预构建库:
However, I am adding Crosswalk using the suggested plug-in, thus I get pre-built libraries without proprietary codecs:
phonegap plugin add cordova-plugin-crosswalk-webview --variable XWALK_MODE="lite" --save
如何将专有编解码器集成到Cordova Crosswalk插件中?
How can I integrate proprietary codecs in the Cordova Crosswalk plug-in?
推荐答案
<我设法理解了构建一切的(复杂的)过程。这个答案涉及编译完整的人行横道的自定义版本(不是精简版)的过程。
I managed to understand the (convoluted) process of building everything. This answer deals with the process of compiling a custom build of the full Crosswalk (not the lite version).
实际上,我决定最终使用标准版本,并用MP3替换AAC音频,但我认为此答案可能对将来参考有用。
Actually, I decided to finally use the standard build and replace AAC audio with MP3s, but I thought this answer could be useful for future reference.
我在Ubuntu 16.04 Docker容器中编译了Crosswalk,以避免污染我的系统并确保我拥有正确的Linux版本。标准映像是准系统,因此我安装了一些依赖项。我还设置了一个共享文件夹来访问已编译的文件:
I compiled Crosswalk in a Ubuntu 16.04 Docker container to avoid "polluting" my system and to ensure I had the right Linux version. The standard image is pretty barebones so I installed some dependencies. I also set up a shared folder to access the compiled files:
docker run -it -v /home/andrea/shared:/shared ubuntu:16.04 /bin/bash
apt update
apt install -y python git nano lsb-release sudo wget curl software-properties-common
export EDITOR=nano # life it too short to learn vi
最后,有必要添加多元存储库:
apt-add-repository multiverse
注意:此过程需要很多空间。在继续操作之前,请确保至少有25GB的可用空间。
Note: this procedure needs a lot of space. Make sure to have at least 25GB of free space before continuing.
要求
按照
Requirements
Install the depot_tools
as outlined in the documentation:
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH=$PATH:/path/to/depot_tools
使用以下命令初始化工作目录:
Initialize a working directory with:
mkdir crosswalk-checkout
cd crosswalk-checkout
export XWALK_OS_ANDROID=1
gclient config --name src/xwalk https://github.com/crosswalk-project/crosswalk.git
然后使用 nano .gclient
编辑配置文件,并添加以下行:
Then edit the config file with nano .gclient
and add the following line:
target_os = ['android']
保存f
尝试与以下对象进行首次同步:
Attempt a first sync with:
gclient sync
此命令将失败,但可以。指令说:
This command will fail but it's OK. The instructions say:
不要担心
gyp_xwalk
是否由于缺少依赖项而失败;安装它们的内容将在后面的部分中介绍,之后您可以再次手动运行gyp_xwalk
。
Do not worry if
gyp_xwalk
fails due to missing dependencies; installing them is covered in a later section, after which you can rungyp_xwalk
manually again.
调整 install-build-deps.sh
文件,然后运行它:
Adjust the install-build-deps.sh
file and then run it:
sed -si "s/msttcorefonts/ttf-mscorefonts-installer/g" src/build/install-build-deps.sh
sudo ./src/build/install-build-deps-android.sh
再次运行 gclient sync
并等待直到正确完成。
Run gclient sync
again and wait until it finishes correctly.
通过检查文件 src / xwalk /build/common.gypi
和 src / tools / mb / mb_config.pyl
,我们可以看到我们需要添加 ffmpeg_branding = Chrome
。
By inspecting the files src/xwalk/build/common.gypi
and src/tools/mb/mb_config.pyl
, we can see that we need to add ffmpeg_branding="Chrome"
in the build arguments.
为防止以后出现错误,请安装与libnotify相关的开发包:
To prevent an error later on, install the development package related to libnotify:
sudo apt install libnotify-dev
移动到 src
目录并打开配置:
Move to the src
directory and open the configuration:
cd src/
gn args out/Default
确保内容如下:
import("//xwalk/build/android.gni")
target_os = "android"
is_debug = false
ffmpeg_branding = "Chrome"
use_sysroot = false
参数 use_sysroot = false
可以防止出现另一个错误。保存文件时,您应该会看到以下内容:
The parameters use_sysroot = false
prevents yet another error. When saving the file, you should see something like this:
Waiting for editor on "/home/utente/crosswalk-checkout/src/out/Default/args.gn"...
Generating files...
Done. Wrote 6060 targets from 1003 files in 2416ms
问题 cd ..
并再次运行 gclient sync
。
最后,要构建核心库,请执行以下操作:
Finally, to build the core library do:
cd src/
ninja -C out/Default xwalk_core_library
这将为ARM构建库,并生成位于以下位置的AAR文件:
This will build the library for ARM, producing an AAR file located at:
src/out/Default/xwalk_core_library.aar
将此文件安全地复制
使用以下方法返回args:
Get back to the args with:
gn args out/Default
添加以下行:
target_cpu = "x86"
保存文件,再次运行 gclient sync
,然后重复 ninja
命令。复制现在包含x86库的新AAR文件。
Save the file, run gclient sync
again and then repeat the ninja
command. Make a copy of the new AAR file which now contains the x86 libraries.
标准的Cordova Crosswalk插件将单个AAR文件与两个平台的库一起使用。 Raphael Kubo da Costa的此消息建议如何制作此单个存档:
The standard Cordova Crosswalk plug-in uses a single AAR file with libraries for both platforms. This message by Raphael Kubo da Costa suggests how to produce this single archive:
AAR文件只是zip文件; 鉴于ARM
和x86 AAR文件之间的唯一区别是共享库不同,因此可以使用
之类的zipmerge
之类的东西合并zip文件(甚至
都将其提取到某个目录中,然后创建一个新的zip文件)
来构建一个最终的多架构AAR归档文件。
AAR files are just zip files; given the only difference between the ARM and x86 AAR files are the different shared libraries, you can use something like
zipmerge
or anything that merges zip files (or even extract everything into some directory and then create one new zip file) to build one final, multi-architecture AAR archive.
最后,要在科尔多瓦插件中使用自定义构建的AAR文件,请参见如何更改Cordova Crosswalk Webview插件使用的Crosswalk版本。
Finally, to use the custom built AAR file in the Cordova plug-in, see How to change the Crosswalk version used by the Cordova Crosswalk Webview plugin.
这篇关于在使用Cordova插件时如何向Crosswalk添加媒体编解码器支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!