apache / cordova-plugin-media

Apache Cordova Media Plugin
https://cordova.apache.org/
Apache License 2.0
388 stars 768 forks source link

Android 11 Media player not working , Android SDK 30 #315

Open 21pg opened 2 years ago

21pg commented 2 years ago

Bug Report

After I upgrade to android 11 , I am getting problem with cordova-plugin-media player. Its not playing audio stream .. on checking status its always at 1.

Problem

What is expected to happen?

It should play audio stream..

What does actually happen?

A continuous loop is going on play button.

Information

Command or Code

 `<?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="28">
 <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>`

Environment, Platform, Device

android 10.0.1

Version information

Checklist

21pg commented 2 years ago

Nothing works for me.. I Have an app builder, In which 20K apps that depends on this plugin (required this feature)- I don't required to record and play. We use live stream e.g (-[(http://streams.radiobob.de/bob-chillout/aac-64/streams.radiobob.de/)]) and just want to play this audio stream on button click.. When I click play button, output is: Error: 1

syslogic commented 2 years ago

This is the same alike on StackOverflow, nothing but some config file, without the least code or stack-trace - which isn't reproducible. For me it probably would be easy to fix (besides I see no motivation to do so)... better cut all this abstract fluff out and provide hard facts. Nobody cares what you do with that plugin... this doesn't make the issue any more important, but rather raises the question why you don't reinvest in software maintenance?

21pg commented 2 years ago

This is the same alike on StackOverflow, nothing but some config file, without the least code or stack-trace - which isn't reproducible. For me it probably would be easy to fix (besides I see no motivation to do so). better cut all this abstract fluff out and provide hard facts. Nobody cares what you do with that plugin... this doesn't make the issue any more important, but rather raises the question why you don't reinvest in software maintenance?

I truly expected a solution here (If nothing a kind reply at least) I bet you don't care.. but we do care Issue easily reproducible using on Android 11 I used a very basic cordova app with only using cordova-plugin-media and build over android sdk = 30

breautek commented 2 years ago

Does the stream offer https:// version? Error code 1 is aborted and android is known to reject non-secure http paths.

Ref: https://github.com/apache/cordova-plugin-media/blob/master/www/MediaError.js#L46

21pg commented 2 years ago

Does the stream offer https:// version? Error code 1 is aborted and android is known to reject non-secure http paths.

Ref: https://github.com/apache/cordova-plugin-media/blob/master/www/MediaError.js#L46 Yes stream works on - https also http://streams.radiobob.de/bob-chillout/aac-64/streams.radiobob.de/ I tried few more streams - https://stream1.datenkollektiv.net/ginseng.mp3 https://radiopotsdam-live.cast.addradio.de/radiopotsdam/live/mp3/high/stream.mp3 https://stream1.thepuremix.net/nexusdance_low.aac

breautek commented 2 years ago

Yes stream works on - https also

So can this issue be closed? Preferably you should always use https when available. Android starting in API 28 has disabled clear text (e.g. non-encrypted traffic) by default.

If for some reason you cannot use https, then you'll need to allow clear text traffic. Cordova doesn't provide an interface to do this, you'll need to craft the appropriate xml yourself.

21pg commented 2 years ago

No, its not working, I said, stream available on both https:// and http:// version I have tried few more stream but its not working, http or https both.. Is there issue anything related to mp3.. ?

breautek commented 2 years ago

I've reproduced your issue -- I observed that the media starts but then closes the stream immediately. I'm not sure of the reason.

I also tested it with simply the HTML <audio> controls -- that does appear to work as expected with the https url. Like I mentioned before, android by default blocks http:// urls. Using the HTML5 may be a workaround for you for the time being.

I only tested with https://streams.radiobob.de/bob-chillout/aac-64/streams.radiobob.de/ stream.

21pg commented 2 years ago

I am getting issue with mp3 streams only... however, I made changes as per your suggestion using html 5 for now(temporarily), its working for me.. but need any solutions asap...

EmersonAlves commented 2 years ago

Add this permission in the config.xml file to fix image

breautek commented 2 years ago

Add this permission in the config.xml file to fix image

Note that using manage external storage permission requires justification when uploading to google play store. Google may reject the app if they believe you don't need broad file system access.

21pg commented 2 years ago

Add this permission in the config.xml file to fix image

Tried, but not working for me.. I am getting problem with some stream e.g.- https://streaming.fueralle.org/ginseng.mp3 for some reason I can't use HTML5 ..

erisu commented 2 years ago

When I tested streaming with the above example audio file, I didnt see any issues.

My Project

Test Environment

Use Cases

First Use Case

Second Use Case

Notes