Questions tagged [android-mediaplayer]
MediaPlayer class can be used to control playback of audio/video files and streams in Android devices
4,798
questions
0
votes
0
answers
24
views
Trick play thumbnail on exoplayer media3
I'm working with an HLS playlist that provides #EXT-X-IMAGE-STREAM-INF tag containing thumbnails for every 10 seconds of video frames. Currently, I'm using ExoPlayer Media3 for video streaming on ...
0
votes
0
answers
21
views
How to use MediaPlayer properly with Kotlin to reproduce sounds?
I have two buttons (one for successes and another one for fails). I want to reproduce a different sound when clicking on each button. Each button will be clicked like 100 times before destroying the ...
0
votes
0
answers
14
views
Kotlin Media Player: How to get the filename of a resource id (resid)?
I'm using the MediaPLayer to play the following mp3-file via the resid, e.g. 2131623940:
Abstract of the code:
if (mp == null) {
mp = MediaPlayer.create(this, ...
0
votes
0
answers
18
views
How to play Android MediaPlayer using InputStream without tempFile
I want to receive an InputStream and play it with MediaPlayer
In 23 and higher, playback was successful using MediaDataSource.
However, under 23, I want to play it without creating a separate tempFile ...
0
votes
1
answer
27
views
Android Studio Media Player won't stop after orientation change
If I change the orientation of the phone the music would keep playing which is good but it won't pause or stop either.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(...
1
vote
1
answer
25
views
In Android MediaSessionCompat.Callback onSeekTo() how to detect event is from the notification player
The MediaSessionCompat.Callback onSeekTo() callback always passes the absolute position in the media being played. However, there are cases in my app that deal at the chapter level (the entire media ...
0
votes
1
answer
54
views
Modify my Tensorflow Lite output to process and display video frames sequentially
I have this simple piece of code (from here) that applies a TensorfFlow Lite model on an input image (of size 480x270) and after processing, it shows the resulting image. Works fine although the ...
0
votes
0
answers
44
views
Why NotificationCompat MediaStyle notification is not showing all five buttons in expanded view in Android
I am trying to show 5 actions in the expanded media notification in Android but no matter, both the collapsed and expanded notifications are only showing three actions (prev, play/pause, next). In ...
0
votes
0
answers
11
views
MediaHTTPConnection Error in Android MediaPlayer
I'm working on an Android app, and I'm facing an issue with the MediaPlayer in my code. When I try to create a new MediaPlayer instance using createMediaPlayer(), I encounter the following error:
main ...
0
votes
0
answers
12
views
How to play animation(videoView) and mediaPlayer at the same time?
I am working on a foreground service which when created, creates MediaPlayer and an Activity whose View has a custom button that should repeat an animation every 2 seconds. The animation is an mp4 ...
0
votes
0
answers
10
views
How to intercept "double click" via Bluetooth on MediaPlayer
I'm building a Mobile App which has a MediaPlayer.
It interacts nice with Bluetooth triggers (play, stop, next, prev, long next, long prev), but I'd like to intercept an action as "double click&...
0
votes
0
answers
18
views
Why cant play HTTPS streams in Exoplayer
Exolayer can not stream from HTTPS , how to resolve?
0
votes
1
answer
36
views
Android MediaPlayer - Which extension to use?
I read about how to play a sound using the MediaPlayer API, however, I have no idea what file extension I should use. It is for a custom notification sound, and I'm sure MP3 could be the way to go, ...
0
votes
1
answer
27
views
Android MediaPlayer setVolume not working properly
when i use the function setVolume(left,right) the volume of the song is affected just by left volume, right can be whatever number, mp just does not care. The volume changes correctly on both ears, ...
0
votes
1
answer
19
views
how to implement Mediaplayer.OnPreparedlistener in kotlin
i read the documentation
Documentation
but still have no idea how to implement it in kotlin, i tried searching it on google but all answer is java so, how do i implement onpreparedlistener on kotlin?
0
votes
1
answer
19
views
how to prevent mediaplayer to overlapping audio?
i was building a button for playing my music but there is a problem, i am building this project with recyclerview and i want it that if i pressed button for music 1, and then i pressed the button for ...
0
votes
1
answer
52
views
Start playing multiple audio files in the same time in Android with Java
I'm working on music project in Android with Java which I need to start multiple audio files exactly at the same time and I need them to be simultaneously without any gaping even if it's milliseconds
...
1
vote
2
answers
27
views
MediaPlayer not looping a raw resource MP3 file (Kotlin)
Can someone help me to loop my audio source? I'm new to using the MediaPlayer, but I cannot get it to loop the sound. The sound plays, then quits and never starts up again.
I have read countless ...
0
votes
0
answers
23
views
When to allow MediaSessionCompat.onPlay, and when to disallow at start for Android Auto?
I have an Android media app for playing music. I register a service inside AndroidManifest.xml. When my app is started and my service is sent onCreate() I create a MediaSessionCompat and register a ...
0
votes
1
answer
39
views
How to detect if Android Auto is starting, so I can set the initial PlaybackState?
According to the Android app quality for cars guideline MA-1:
Media apps must not autoplay on startup or without user initiated action to select the app or app media..
The guidelines suggest reading ...
0
votes
0
answers
21
views
CurrentPosition of Media player restarts to zero while playing in Kotlin
In the ViewHolder of my Recycler view I play an audio with Media Player and I show the progress with a Progress Bar. The problem is that suddently the current progress restarts. I don't know why this ...
0
votes
0
answers
18
views
Media Player is not starting on the service
binding.btPlay.setOnClickListener {
Intent(this,MusicService::class.java).also {
it.action=MusicService.Action.START.toString()
startService(it)
...
0
votes
0
answers
26
views
How turn off any media that is currently playing on the phone with kotlin, and sleep wifi and bluetooth (Android TIRAMISU)
I tried a lot of things as MediaPlayer, WifiManager, BluetoothAdapter and read a lot of docs but I don't find anything which works and which is not deprecated with android 13.
Thanks for your time, I'...
0
votes
1
answer
171
views
Media3 ExoPlayer getMediaMetadata() do not get correct data
I'm trying to create a very simple app - a online radio player, and I want to get the name of the song currently playing. Here is the code:
player = new ExoPlayer.Builder(this).build();
...
0
votes
0
answers
125
views
Android media controller in jetpack compose
I am trying to create a section in my android launcher that should directly control audio playback(like songs on Spotify, Audible, Wink ,etc.) but creating it is harder than it seems.
after searching ...
1
vote
3
answers
99
views
Android ANR when trying to release and stop MediaPlayer
I have the following method which simply request a .mp3 file from a URL, loads a MediaPlayer and shows or hide the play button depending if the URL was loaded or not:
public class PlayMusicFragment ...
0
votes
0
answers
57
views
Fatal Exception: android.app.RemoteServiceException: Bad notification for startForeground when using setMediaNotificationProvider in media3
I have made a music app recently using media3 version 1.1.0. I was trying to customize the media notification by using setMediaNotificationProvider in onCreate of my MediaSessionService. This is my ...
0
votes
1
answer
35
views
onPause alternative in android service?
I have a android project that requires music to be played in the background. I believe using a service would be the right thing for this so I set one up in the following way:
internal class Song : ...
0
votes
0
answers
81
views
Playing live internet radio on Android auto
I'm trying to devlop my own application to play live internet radio on my phone and make it compatible with android auto. So, I started a new project Android auto on last version of Androit Studio (...
0
votes
0
answers
18
views
Cut or trim audio with wade form view and save it
i want to cut or trim audio with wade form view and save it. But i haven't found a way to solve this problem yet. Thanks for helping me
i try library android-audio-visualizer, and ffmpeg to trim audio....
0
votes
0
answers
25
views
Playing audio files using mediaPlayer library in android programming (kotlin)
i am implementing an android app in kotlin that plays audio through audio files using mediaPlayer library . Everything work well but when an audio is playing , when clicked , the second audio is ...
0
votes
0
answers
10
views
started foreground service for musicapp,not able to listen song when not using foregroundservice able listen sound after using foreground not able
not able to listen audio or song when I started foreground service
I created music app after clicking select button it will take audio file from my storage and it will play the sound .but my condition ...
0
votes
0
answers
15
views
what does frame rate index value of 15 means in AC4 sync frame?
We are parsing AC4 audio segment, in this while parsing sync frame we are getting 15 as frame rate index, but the maximum value of frame rate index is 13, so is there any meaning of 15 as frame rate ...
0
votes
0
answers
24
views
MediaPlayer NullPointerException on Android TV , Version 9
I am continuously getting Crash report from Android TV version 9, It's difficult for me to troubleshoot this because I'm getting this via a crash report from someone else's android tv, It is working ...
0
votes
0
answers
24
views
MediaPlayer and Slider using Foreground Service
I have a mediaplayer inside a foreground service and I'm trying to update my Slider but I'm not seeing a way to do that. I tried creating a static variable but the issue is I'm not able to find a way ...
1
vote
1
answer
32
views
mediaplayer not decreasing volume or stopping
I'm trying to create a method that crossfades between two mediaplayers. One should fade in while the other fades out, as I've done in both of the threads.
void startAudio(String path) throws ...
0
votes
0
answers
51
views
Android MediaPlayer is micro pausing every 20 seconds
I'm trying to play audio via a url but Android MediaPlayer is micro pausing every 20 seconds. I've tried multiple internet connections and the issue is pretty consistent. Local files do not have this ...
0
votes
0
answers
23
views
Amazon Fire Tv: Video playback at input volume level
Requirement: Volume control without UI intervention. The client app getting different videos to play in VideoView and it usages the MediaPlayer class to control the playback of these video files. ...
0
votes
0
answers
171
views
mediaplayer with notification in android java
I've developed a media player that plays music and displays a notification with controls for play, pause next, and previous functions. I need the app to play its notification in media player just like ...
0
votes
0
answers
10
views
PresetReverb makes MediaPlayer silent
I'm trying to add a PresetReverb to a MediaPlayer. The weird thing is that, without it, the audio plays normally. But if I add the PresetReverb, no sound is playing. Here's what I tried:
...
0
votes
2
answers
146
views
android.media.audiofx how to create a 10 band equilizer
I am trying to write my own MP3 player using .NET MAUI.
One of the libraries are based on android media player. As I read in the documentation it has an Equalizer class in the android.media.audiofx ...
1
vote
1
answer
118
views
Android `MediaPlayer`'s `prepare` method crashes only in release mode AND on physical devices when used in `MAUI` application
I have the following wrapper for a media player:
public class AndroidAudioPlayer
{
private readonly MediaPlayer player;
private readonly MemoryStream stream;
internal AndroidAudioPlayer(...
0
votes
0
answers
163
views
How to Play Corresponding Sound in LazyColumn in Jetpack Compose?
How to play the corresponding sound in LazyColumn in Jetpack Compose? Like when clicked a play a sound, when clicked b play b sound. I don't want to initialize every sound manually.
val characters = ...
0
votes
0
answers
69
views
How do I remove internal mic sound from the mic when recording audio in android studio?
I want to play a sound file and then record the audio coming out of my phone's mic right after, but the sound file keeps getting caught in the actual recording. Currently I'm having to set a 750 ms ...
0
votes
0
answers
441
views
android.app.ForegroundServiceStartNotAllowedException Service.startForeground() not allowed due to mAllowStartForeground false
i have a mediaplayer java class that connect to service to show notification,
the service dose'nt stop except when user clicks the notification cancel button
notification = new NotificationCompat....
0
votes
0
answers
6
views
Select prenumbered mp3 file for playing in Android Studio
I have a number of mp3 file that are name01, name02 up to name10. The user will enter just the digits and then the mp3 will play.
For example user enters 02 the name02.mp3 will play.
I cannot name the ...
1
vote
1
answer
106
views
How can I change default play/pause icon(for android 13) in notification panel which by default comes with PlaybackStateCompat?
play/pause icon with red marker
I want to change the icon. I tried removing PlaybackStateCompat.ACTION_PLAY and adding customAction, but getting as expected. after adding custom action ...
0
votes
1
answer
90
views
MediaRecorder.prepare() keeps failing and throwing an exception
I have the following function below for my start record button to record audio on my Samsung S20 FE:
private fun startRecording (button: Button) {
recorder = MediaRecorder().apply {
...
0
votes
0
answers
11
views
Syncing Progress of mediaplayer with ObjectAnimator
I'm using the Library -> https://github.com/alxrm/audiowave-progressbar
My target is to play the song in the form of waveform
the problem im facing is when i click on play song started playing but ...
0
votes
0
answers
71
views
"Unable to create media player" and "setDataSource Failed" error. mediaplayer is not getting created when using URI for data source
I'm trying to play sound when my CountDownTimer is finished, but when I try to set data source for media player it throws an exception, I'm setting the data source using URI, and I'm getting that URI ...