Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
21pg opened this issue Sep 28, 2021 · 13 comments
Open
3 tasks done

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

21pg opened this issue Sep 28, 2021 · 13 comments
Labels

Comments

@21pg
Copy link

21pg commented Sep 28, 2021

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

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@21pg
Copy link
Author

21pg commented Sep 29, 2021

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

This comment has been minimized.

@21pg

This comment has been minimized.

@21pg 21pg closed this as completed Sep 29, 2021
@breautek
Copy link

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 21pg reopened this Sep 29, 2021
@21pg
Copy link
Author

21pg commented Sep 29, 2021

@breautek
Copy link

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
Copy link
Author

21pg commented Sep 30, 2021

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 breautek added the bug label Sep 30, 2021
@breautek
Copy link

breautek commented Sep 30, 2021

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
Copy link
Author

21pg commented Oct 5, 2021

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
Copy link

EmersonAlves commented Oct 27, 2021

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

@breautek
Copy link

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
Copy link
Author

21pg commented Dec 7, 2021

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
Copy link
Member

erisu commented May 25, 2022

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

My Project

  • cordova-android 10.1.1
  • cordova-plugin-file: 6.0.2
  • cordova-plugin-media: 5.0.4

Test Environment

  • Emulator: Pixel 4 API 31

Use Cases

First Use Case

  • No custom modifications added to config.xml.
  • App content served from default path https://localhost/

Second Use Case

  • Set AndroidInsecureFileModeEnabled to true in config.xml.
  • App content served from file:///android_asset/www/

Notes

  • This test was done before cordova-plugin-file@7.0.0 release. The outcome shouldnt be effect with the new release.
  • cordova-plugin-file was added by the media plugin. I didn't add it manually.
  • When testing, it took a couple of seconds for the audio to be heard. I suspected it was normal behavior of the stream.
  • If app is served from https scheme trying to stream from the http scheme, it will fail. This is default behavior of any browser since its trying to access something that is insecure.
  • If using LetsEncrypt and running on an old Android device, this might produce unexpected results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants