Questions tagged [android-mediaplayer]

MediaPlayer class can be used to control playback of audio/video files and streams in Android devices

MediaPlayer class can be used to control playback of audio/video files and streams.

4605 questions
138
votes
3 answers

Should have subtitle controller already set Mediaplayer error Android

Whenever I play a media, it shows a warning in DDMS Should have subtitle controller already set MY CODE: private void start() { mediaPlayer.start(); mediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override …
Sai
  • 12,738
  • 15
  • 70
  • 106
131
votes
6 answers

Play audio file from the assets directory

I have the following code: AssetFileDescriptor afd = getAssets().openFd("AudioFile.mp3"); player = new MediaPlayer(); player.setDataSource(afd.getFileDescriptor()); player.prepare(); player.start(); The problem is that, when I run this code, it…
Catalin Morosan
  • 7,693
  • 11
  • 51
  • 73
125
votes
11 answers

Play sound on button click android

How do I get a button to play a sound from raw when click? I just created a button with id button1, but whatever code I write, all is wrong. import android.media.MediaPlayer; public class BasicScreenActivity extends Activity { @Override …
Dmitry
  • 1,309
  • 3
  • 11
  • 10
110
votes
18 answers

Media Player called in state 0, error (-38,0)

I am currently trying to design a simple app that streams an internet radio station. I have the URL for the station and am setting up the Media Player like MediaPlayer mediaPlayer = new MediaPlayer(); try { …
SmashCode
  • 3,912
  • 7
  • 34
  • 53
95
votes
4 answers

What is the difference between MediaPlayer and VideoView in Android

I was wondering if there's a difference between them when it comes to streaming videos. I know VideoView can be used for streaming and what is Mediaplayer for? As far as I know, MediaPlayer can do the same thing as VideoView right? Can anyone give…
oattie
  • 991
  • 2
  • 7
  • 5
88
votes
7 answers

Streaming Audio from A URL in Android using MediaPlayer?

I've been trying to stream mp3's over http using Android's built in MediaPlayer class. The documentation would suggest to me that this should be as easy as : MediaPlayer mp = new…
Pandalover
  • 2,378
  • 3
  • 21
  • 19
69
votes
4 answers

Media Player Looping : Android

I am having 3 secs of mp3 file. I want to play that mp3 file continuously still the user click pause button. Is there any method to loop the single file and play it again again till user pauses it.
Dray
  • 1,796
  • 5
  • 25
  • 41
63
votes
13 answers

SeekBar and media player in android

I have a simple player and recorder. Everything works great but have a one problem. I want to add seek bar to see progress in playing record and use this seek bar to set place from player should play. I have onProgress but with no effect. This is…
edi233
  • 3,017
  • 11
  • 48
  • 86
60
votes
5 answers

How to fit video in Live wallpaper, by center-crop and by fitting to width/height?

Background I'm making a live wallpaper that can show a video. In the beginning I thought this is going to be very hard, so some people suggested using OpenGL solutions or other, very complex solutions (such as this one). Anyway, for this, I've found…
android developer
  • 106,412
  • 122
  • 641
  • 1,128
53
votes
6 answers

Why does it take so long for Android's MediaPlayer to prepare some live streams for playback?

I am finding big differences in the time it takes the Android MediaPlayer to prepare for live stream playback with different streams. The hard data I added logging between prepareAsync() and the onPrepared(MediaPlayer mp) callback and tested several…
45
votes
6 answers

Mediaplayer error (-19,0) after repeated plays

I have a game in which a sound plays when a level is completed. Everything works fine to start with but after repeating a level 10 or 20 times the logcat suddenly reports: "MediaPlayer error (-19,0)" and/or "MediaPlayer start called in state 0" and…
Mick
  • 7,929
  • 20
  • 73
  • 162
42
votes
5 answers

Android - play sound on button click - Null pointer exception

I am trying to play a sound file on the click of a button. The sound is just 1 sec long. It plays well the first few times I click the button, but after a while it gives a NullPointerException. Here's the code: button[i].setOnClickListener(new…
Chris
  • 3,667
  • 12
  • 38
  • 48
39
votes
5 answers

IllegalStateException for MediaPlayer.prepareAsync

05-19 11:52:51.622: ERROR/MediaPlayer(1291): prepareAsync called in state 8 05-19 11:52:51.622: WARN/System.err(1291): java.lang.IllegalStateException try { mp = MediaPlayer.create( Main.this, …
hunterp
  • 14,818
  • 17
  • 56
  • 108
38
votes
3 answers

Media Session Compat not showing Lockscreen controls on Pre-Lollipop

I'm using MediaSessionCompat from AppCompat Support Library Revision 22. And on Lollipop I'm getting notification & also the background of lockscreen is the album art. And everything works cool. While on Pre-Lollipop devices, the music controls on…
37
votes
5 answers

MediaPlayer : Should have subtitle controller already set: KitKat

I am having an odd issue where my audio file sometimes plays and sometimes does not play. The catch is that when it decides to not play, the DDMS gives me an: E/MediaPlayer﹕ Should have subtitle controller already set Because this is one-to-one…
bneigher
  • 778
  • 4
  • 10
  • 23
1
2 3
99 100