简体   繁体   English

在使用Cordova插件时,如何向Crosswalk添加媒体编解码器支持?

[英]How do I add media codecs support to Crosswalk while using the Cordova plug-in?

I'm building a PhoneGap app which needs to play AAC audio. 我正在构建一个需要播放AAC音频的PhoneGap应用程序。 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. 它使用原生WebView很好用,但我想在构建目标API 16-20上使用Crosswalk,因为我的应用程序中的某些CSS功能在Android 4.x上根本不起作用。

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. 当我制作项目的副本以添加Crosswalk Lite时,我可以看到除了指向AAC文件的<audio>元素之外该应用程序正常工作。 This is because Crosswalk does not ship with proprietary codecs by default . 这是因为Crosswalk默认情况下不附带专有编解码器

The linked page says: 链接页面说:

To build Crosswalk with these codecs, a developer must run the build with the “must accept a EULA” switch turned on: 要使用这些编解码器构建Crosswalk,开发人员必须在打开“必须接受EULA”开关的情况下运行构建:

 $ xwalk/gyp_xwalk -Dmediacodecs_EULA=1 

Then build Crosswalk. 然后建立Crosswalk。 The ffmpegsumo.dll or libffmpegsumo.so in the build output directory will contain the proprietary codecs. 构建输出目录中的ffmpegsumo.dlllibffmpegsumo.so将包含专有编解码器。

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: 但是,我使用建议的插件添加Crosswalk,因此我得到了没有专有编解码器的预构建库:

phonegap plugin add cordova-plugin-crosswalk-webview  --variable XWALK_MODE="lite" --save

How can I integrate proprietary codecs in the Cordova Crosswalk plug-in? 如何在Cordova Crosswalk插件中集成专有编解码器?

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). 这个答案涉及编译完整Crosswalk(不是精简版)的自定义构建的过程。

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. 实际上, 我决定最终使用标准版本并用MP3取代AAC音频,但我认为这个答案可能对将来参考有用。

Environment 环境

I compiled Crosswalk in a Ubuntu 16.04 Docker container to avoid "polluting" my system and to ensure I had the right Linux version. 我在Ubuntu 16.04 Docker容器中编译了Crosswalk,以避免“污染”我的系统并确保我拥有正确的Linux版本。 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

Finally, it is necessary to add the multiverse repositories : 最后,有必要添加多元宇宙库

apt-add-repository multiverse

Note: this procedure needs a lot of space. 注意:此过程需要大量空间。 Make sure to have at least 25GB of free space before continuing. 在继续之前,请确保至少有25GB的可用空间。

Requirements 要求

Install the depot_tools as outlined in the documentation : 按照文档中的说明安装depot_tools

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

Then edit the config file with nano .gclient and add the following line: 然后使用nano .gclient编辑配置文件并添加以下行:

target_os = ['android']

Save the file. 保存文件。

Fetching the source 获取源

Attempt a first sync with: 尝试首次同步:

gclient sync

This command will fail but it's OK. 此命令将失败,但没关系。 The instructions say: 说明说:

Do not worry if gyp_xwalk fails due to missing dependencies; 如果gyp_xwalk由于缺少依赖性而失败,请不要担心; installing them is covered in a later section, after which you can run gyp_xwalk manually again. 安装它们将在后面的部分中介绍,之后您可以再次手动运行gyp_xwalk

Adjust the install-build-deps.sh file and then run it: 调整install-build-deps.sh文件,然后运行它:

sed -si "s/msttcorefonts/ttf-mscorefonts-installer/g" src/build/install-build-deps.sh
sudo ./src/build/install-build-deps-android.sh

Run gclient sync again and wait until it finishes correctly. 再次运行gclient sync并等待它正确完成。

Building 建造

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. 通过检查文件src/xwalk/build/common.gypisrc/tools/mb/mb_config.pyl ,我们可以看到我们需要在构建参数中添加ffmpeg_branding="Chrome"

To prevent an error later on, install the development package related to libnotify: 要防止以后出现错误,请安装与libnotify相关的开发包:

sudo apt install libnotify-dev

Move to the src directory and open the configuration: 移动到src目录并打开配置:

cd src/
gn args out/Default

Ensure the content is as follows: 确保内容如下:

import("//xwalk/build/android.gni")
target_os = "android"
is_debug = false
ffmpeg_branding = "Chrome"
use_sysroot = false

The parameters use_sysroot = false prevents yet another error. 参数use_sysroot = false可防止出现另一个错误。 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

Issue cd .. and run gclient sync again. 发出cd ..并再次运行gclient sync

Finally, to build the core library do: 最后,构建核心库做:

cd src/
ninja -C out/Default xwalk_core_library

This will build the library for ARM, producing an AAR file located at: 这将为ARM构建库,生成位于以下位置的AAR文件:

src/out/Default/xwalk_core_library.aar

Copy this file in a safe place. 将此文件复制到安全的地方。

Building for x86 为x86构建

Get back to the args with: 回到args:

gn args out/Default

Add the following line: 添加以下行:

target_cpu = "x86"

Save the file, run gclient sync again and then repeat the ninja command. 保存文件,再次运行gclient sync ,然后重复ninja命令。 Make a copy of the new AAR file which now contains the x86 libraries. 制作新的AAR文件的副本,该文件现在包含x86库。

Using the AAR files 使用AAR文件

The standard Cordova Crosswalk plug-in uses a single AAR file with libraries for both platforms. 标准的Cordova Crosswalk插件使用单个AAR文件和两个平台的库。 This message by Raphael Kubo da Costa suggests how to produce this single archive: Raphael Kubo da Costa的这条消息建议如何制作这个单一档案:

AAR files are just zip files; AAR文件只是zip文件; 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. 鉴于ARM和x86 AAR文件之间的唯一区别是不同的共享库,你可以使用像zipmerge或任何合并zip文件的东西 (甚至将所有东西都提取到某个目录然后创建一个新的zip文件)来构建一个final,多架构AAR存档。

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插件中使用自定义构建的AAR文件,请参阅如何更改Cordova Crosswalk Webview插件使用的Crosswalk版本

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

相关问题 使用Cordova蓝牙带有BLE设备的串行插件 - Using cordova bluetoothSerial plug-in with a BLE device 如何通过JavaScript /或Cordova插件调用/启动Android onResume? - How to call/initiate Android onResume from JavaScript/ or a Cordova plug-in? 如何从Cordova插件类迫使Android应用程序崩溃? - How to force a crash of Android app, from a Cordova plug-in class? 我想在使用Android Eclipse ADT插件的同时自定义构建过程 - I want to customize the build process while still using the Android Eclipse ADT plug-in 在Android中将Cordova与Crosswalk结合使用时使用自定义插件 - Using a custom plugin while using Cordova with Crosswalk in Android 如何通过JNI使用Android OpenCORE编解码器? - How do I use Android OpenCORE codecs using JNI? 为什么我使用PhoneGap和条形码扫描仪插件不断收到“找不到用于处理Intent的活动”? - Why do I keep getting “No activity found to handle Intent” using PhoneGap and the barcode scanner plug-in? 我可以为Android Mail Client创建附加组件或插件吗? - Can I create Add-on or Plug-in for Android Mail Client? 如何在Phonegap中安装插件 - How to Install plug-in in Phonegap 如何在Windows上为Android安装Crosswalk - How do i install crosswalk for android on windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM