question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android only] Audio file doesn't play

See original GitHub issue
import {Media, MediaObject} from "@ionic-native/media/ngx";

  constructor(
      private media: Media,
  ) { }
      const mp3file: MediaObject = this.media.create(url);
      mp3file.play();

On iOs the code above is working properly, however on Android no sound is coming out and I have no error message.

Any idea ?

_Ionic:

Ionic CLI : 5.4.15 Ionic Framework : @ionic/angular 5.0.0 @angular-devkit/build-angular : 0.803.23 @angular-devkit/schematics : 8.1.3 @angular/cli : 8.1.3 @ionic/angular-toolkit : 2.1.2

Cordova:

Cordova CLI : 9.0.0 (cordova-lib@9.0.1) Cordova Platforms : android 8.1.0, browser 6.0.0, ios 5.0.1 Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.1, (and 11 other plugins)

Utility:

cordova-res : not installed native-run (update available: 1.0.0) : 0.2.8

System:

Android SDK Tools : 26.1.1 (/Users/merwanropers/Library/Android/sdk) ios-deploy : 1.9.4 NodeJS : v14.0.0 (/usr/local/Cellar/node/14.0.0/bin/node) npm : 6.14.4 OS : macOS Catalina Xcode : Xcode 11.4 Build version 11E146_

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

9reactions
brunocbatistacommented, Jun 1, 2020

(Sorry for any mistake, English is not my official language.)

I have a solution for android 10.

  1. Add to your <edit-config> in the config.xml file: <application android:requestLegacyExternalStorage="true" />

  2. Make sure that the build.gradle in the /platforms/android/ folder has the variables configured for sdk api level 29: defaultBuildToolsVersion = “29.0.0” defaultMinSdkVersion = 19 defaultTargetSdkVersion = 29 defaultCompileSdkVersion = 29

  3. Finally, make sure your build is running at sdk’s api level 29.

The error happens due to a lack of android permission on the external storage folder (android 10 updates).

Links that I used as a basis to develop the solution https://medium.com/@sriramaripirala/android-10-open-failed-eacces-permission-denied-da8b630a89df https://github.com/geosparks/geospark-cordova-example/issues/3#issuecomment-558510384

0reactions
karmdip-micommented, Mar 9, 2022

Hello @Merwan1010

I did the same code (https://github.com/apache/cordova-plugin-media/issues/277#issuecomment-624503732) in My Application But Audio file is not playing

mp3file.release(); // Don't forget to release ! Otherwise the audio won't play on Android after a certain amount of media created.

But I just debugged the code for the resolve the issue at that time I Just comment that mp3file.release() and audio file is playing fine so I am confused as per plugin it’s must release the file in Android but it’s working fine after comment that particular line So can you please guide me for this

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Audio FIles Won't play - Android Forums at AndroidCentral.com
I was able to listen to music, play videos, and talk on the phone. This only lasted 5 days. i dont want to...
Read more >
10 Methods: How to Solve Audio File Not Playing
Part 2: Troubleshooting Audio File Not Playing Issue · Method 1: Install Audio Codecs · Method 2: Choose Correct Audio Speaker · Method...
Read more >
Audio (not) playing in Android app - Uptech
The situation was like this: I needed multiple audio files to be played at once. ... We won't speak of the video specifics,...
Read more >
Audio files wont play - Google Drive Community
right click on the sound/speaker icon at the right below and turn off spatial sound. This works for me after so many months...
Read more >
Can't play full audio files - Android Enthusiasts Stack Exchange
2) After going back to google basics and figuring out a better way to ask, it looks like it might be an issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found