cordova Android 11媒体播放器不工作,Android SDK 30

5sxhfpxr  于 2022-11-15  发布在  Android
关注(0)|答案(2)|浏览(268)

我升级到Android 11(API 30)后,我得到了cordova插件媒体的问题。它不播放音频流。当我点击播放音频,输出是:Error:1(这是指MediaError.MEDIA_ERR_ABORTED = 1)我有一个应用程序生成器,其中20 K应用程序依赖于此插件(需要此功能)-我不需要记录和播放。我们使用Web流,例如(-[(http://streams.radibob.de/bob-chillout/aac-64/streams.radibob.de/)]),只想在单击按钮时播放此音频流。这里是config.xml,我正在使用-

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:gap="http://phonegap.com/ns/1.0" id="app.*********" version="3.6.1" android-versionCode="30">
<name>******</name>
<description />
<author href="444656972743" email="">*********</author>
<preference name="orientation" value="portrait" />
<preference name="fullscreen" value="false" />
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
<preference name="android-build-tool" value="gradle" />
<preference name="SplashScreenDelay" value="3000" />
<preference name="AllowInlineMediaPlayback" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="android-minSdkVersion" value="22" />
<preference name="android-targetSdkVersion" value="30" />
<feature name="NetworkStatus">
    <param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" 
 />
</feature>
<feature name="SocialSharing">
    <param name="android-package" value="nl.xservices.plugins.SocialSharing" />
</feature>
<feature name="InAppBrowser">
    <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser" />
</feature>
<feature name="Notification">
    <param name="android-package" value="org.apache.cordova.dialogs.Notification" />
</feature>
<feature name="PushPlugin">
    <param name="android-package" value="com.plugin.gcm.PushPlugin" />
</feature>
<plugin name="cordova-plugin-keyboard" source="npm" spec="1.2.0" />
<plugin name="cordova-plugin-device" source="npm" spec="1.1.7" />
<platform name="android">
    <preference name="AndroidXEnabled" value="true" />
    <preference name="AndroidInsecureFileModeEnabled" value="true" />
    <resource-file src="google-services.json" target="app/google-services.json" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <icon src="icons/android-ldpi.png" density="ldpi" />
    <icon src="icons/android-mdpi.png" density="mdpi" />
    <icon src="icons/android-hdpi.png" density="hdpi" />
    <icon src="icons/android-xhdpi.png" density="xhdpi" />
    <icon src="icons/android-xxhdpi.png" density="xxhdpi" />
    <icon src="icons/android-xxxhdpi.png" density="xxxhdpi" />
    <icon src="icons/android-xxhdpi.png" density="fr-xxhdpi" />
    <splash src="splashscreen/android-ldpi.png" density="ldpi" />
    <splash src="splashscreen/android-mdpi.png" density="mdpi" />
    <splash src="splashscreen/android-hdpi.png" density="hdpi" />
    <splash src="splashscreen/android-xhdpi.png" density="xhdpi" />
    <splash src="splashscreen/android-xxhdpi.png" density="fr-xhdpi" />
    <splash src="splashscreen/android-xxhdpi.png" density="land-xxhdpi" />
    <splash src="splashscreen/android-xxhdpi.png" density="port-xxhdpi" />
    <splash src="splashscreen/android-xxxhdpi.png" density="xxxhdpi" />
    <preference name="KeepRunning" value="true" />
  </platform>
  <access origin="*" subdomains="true" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="https://www.youtube.com/*" />
<allow-navigation href="http://www.youtube.com/*" />
<allow-navigation href="https://player.vimeo.com/*" />
<allow-navigation href="http://player.vimeo.com/*" />
<plugin name="cordova-plugin-media" spec="~5.0.3">
    <variable name="KEEP_AVAUDIOSESSION_ALWAYS_ACTIVE" value="NO" />
</plugin>
<plugin name="cordova-plugin-androidx-adapter" source="npm" spec="1.1.1" />
<plugin name="cordova-plugin-camera" source="npm" spec="4.0.3" />
<plugin name="cordova-plugin-inappbrowser" source="npm" spec="4.0.0" />
<plugin name="cordova-plugin-globalization" source="npm" spec="1.0.9" />
<plugin name="cordova-plugin-network-information" source="npm" spec="2.0.1" />
<plugin name="cordova-plugin-splashscreen" spec="^4.0.3" />
<plugin name="cordova-plugin-x-socialsharing" source="npm" spec="6.0.0" />
<plugin name="cordova-plugin-dialogs" source="npm" spec="2.0.1" />
<plugin name="cordova-sqlite-evcore-extbuild-free" spec="0.14.0" source="npm" />
</widget>

感谢您提供任何解决方案或变通方法..

pxiryf3j

pxiryf3j1#

https://github.com/apache/cordova-plugin-media中有一个新的更新,涵盖了android 11+的保存文件路径问题。
如果您在项目中更新了“/platforms/android/app/src/main/java/org/apache/cordova/media/AudioHandler.java“和“/platforms/android/app/src/main/java/org/apache/cordova/media/AudioPlayer.java“,那么它应该可以正常工作。
https://raw.githubusercontent.com/apache/cordova-plugin-media/4093f7e14fe65f94ffbef072ed188a0205e78a59/src/android/AudioHandler.java
https://raw.githubusercontent.com/apache/cordova-plugin-media/4093f7e14fe65f94ffbef072ed188a0205e78a59/src/android/AudioPlayer.java

ars1skjm

ars1skjm2#

幸运的是,cordova-plugin-media的官方版本也解决了这个问题:
cordova-plugin-media@5.0.4

相关问题