media-player

Headphone Jack Listener Android

*爱你&永不变心* 提交于 2019-11-30 21:07:25
Does anyone know how I can detect if the headphone jack on a device is unplugged on Android? I have a music player and I need to pause the music when the headphones are unplugged. The closest thing I have found is using the AudioManager . Is that the right direction to go? This is what I ended up doing: private class NoisyAudioStreamReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(intent.getAction())) { pause(); } } } private IntentFilter intentFilter = new IntentFilter(AudioManager.ACTION

How to play multiple ogg or mp3 at the same time..?

烂漫一生 提交于 2019-11-30 20:21:49
问题 I'm trying to play 20 ogg files at the same time using MediaPlayer. This is because I want to make a mixing effect. While one music is playing, other files also have to be played. Actually, I already made an application with this function by iOS, and it didn't have any problems to play and mix. And now, I should convert this app into android app. so I sentenced 20 mediaplayer variables MediaPlayer player1; MediaPlayer player2; MediaPlayer player3; ..... play1 = (Button)findViewById(R.id.btn1)

Playing two sounds Simutaneosly

China☆狼群 提交于 2019-11-30 19:53:13
I am trying to play two sounds simutaneosly in android.I have created two MediaPlayers and am using the code below.They are currently playing one after another.Or not exactly one after another but kinda delayed into eachother. private void playSound(){ if (mp1 != null) { mp1.release(); } if (mp2 != null) { mp2.release(); } mp1 = MediaPlayer.create(this, soundArray[0]); mp2 = MediaPlayer.create(this, soundArray[3]); mp1.start(); mp2.start(); } Thanks Emile Vrijdags Playing two digital sounds simultaneously is as simple as summing them together (as in the real world), so you could do that

Select a music file to play with MediaPlayer

☆樱花仙子☆ 提交于 2019-11-30 19:09:54
问题 I'm new in android programming and now i get a problem with my app. I intend to code a MediaPlayer application with feature: select a file from storage using intent then start playing that file. I use "MediaPlayer.create(context, uri)" method but currently i got error protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //openFile(); Button openFile = (Button) this.findViewById(R.id.ButtonOpen); openFile

Exo player DASH Streaming example

此生再无相见时 提交于 2019-11-30 17:23:16
I'm trying to play DASH video on android devices with the ExoPlayer from Google ( http://developer.android.com/guide/topics/media/exoplayer.html ). The documentation is very, very poor and I cannot find some simplest working example with DASH (if someone did it). In the video ( https://www.youtube.com/watch?v=6VjF638VObA#t=462 ) it looks simple but in reality there is a lot of unknown objects. I want to use only ExoPlayer library and without using their github demo because it is very complex and I didn't find a way to add my testing URL because all samples are from YouTube. Thanks Here is a

How to play multiple .wav files simultaneously in delphi

家住魔仙堡 提交于 2019-11-30 16:26:34
I wish to multiple .wav files simultaneously in delphi. When I open and plat the first things are fine. However the second one causes a error when it tries to open. It would appear that i can only use one media player at a time.... is there any way around this what do i do? Andreas Rejbrand How would you play a single sound? When I want fine control, I use the waveOut functions, as in this answer . My answer there also allows you to play the sound using a thread (that is, among other things, asynchronically). I think that you can play two sounds at the same time, by simply starting two such

MediaPlayer error: pause called in state 64

痞子三分冷 提交于 2019-11-30 13:13:02
问题 I am using a MediaPlayer in my Activity . When I hit the back button, I get this error: 09-20 19:44:16.540: E/MediaPlayer(1822): pause called in state 64 09-20 19:44:16.540: E/MediaPlayer(1822): error (-38, 0) Code public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { if (mp!= null && mp.isPlaying()) { mp.stop(); } Intent intentstart = new Intent(X.this, Y.class); intentstart.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

Detect if a VideoVIew is buffering

孤街浪徒 提交于 2019-11-30 11:29:21
Does anyone know if it's possible to detect when a VideoView is buffering? I want to show a ProgressDialog when the video is buffering. So far I tried using a OnPreparedListener, but that only works when the video is first loaded. If a video is playing and the user moves the scrub bar to a different point the video is still "prepared" even though it is buffering. I also tried (I know this is awful) an AsyncThread that just busy waits on isPlaying(): private class BufferTask extends AsyncTask<Void, Void, Void> { protected Void doInBackground(Void...voids) { final VideoView videoView =

Android Media Player play/pause Button

╄→尐↘猪︶ㄣ 提交于 2019-11-30 11:25:46
问题 In my project, I am playing music file in android media player by using the following code MediaPlayer mPlayer = MediaPlayer.create(MyActivity.this, R.raw.myfile); mPlayer.start(); the above is coded in the onclick of the play button. I want to pause the playback by clicking the same button again.ie) single button for play/pause. How shall i do this. 回答1: You could use simple if-check to handle the pausing. Try this: if(mPlayer.isPlaying()){ mPlayer.pause(); } else { mPlayer.start(); } 回答2:

WPF: Implementing a MediaPlayer Audio / Video Seeker

此生再无相见时 提交于 2019-11-30 10:37:48
I am currently working on an MP3 player (in a WPF application) with a WPF MediaPlayer and basically, I want to implement a Song Seeker which moves along with the current playing song. I already implemented a song slider (from Sacha Barber's application ) and it works when the user drags the seeker manually (as in, the song continues from that position) but I cannot figure out how to make the seeker move according to the current position in the song. Trouble is I don't think there is a way to check when the Position property of the MediaPlayer has changed, so I'm stumped as to how I should