media-player

Open MediaPlayer - event unhandled in Thread

混江龙づ霸主 提交于 2019-12-20 05:36:07
问题 I'm trying to create a media player (with Media.MediaPlayer() class) and for this I am using a thread to process the songs that are loaded by the user using the OpenFileDialog. I am using the next code to start the process the songs: public static List<MediaFile> MediaList = new List<MediaFile>(); public static Queue<String> MediaFilesQueue = new Queue<String>(); public static void AddMediaFilesToMediaList() { String pathToFile; while (MediaFilesQueue.Count > 0) // all the files are loaded

Can I use Basic HTTP Authentication with Android MediaPlayer?

坚强是说给别人听的谎言 提交于 2019-12-20 04:30:08
问题 I cant find a way to use an url that requires basic auth when im useing mp.setDataSource(url); MediaPlayer mp = new MediaPlayer(); mp.setDataSource(url); mp.prepareAsync(); Anyone that got any ideas? 回答1: This worked for me: public void setupMediaPlayer(){ // Setup Media Player and Prepare to Play media = new MediaPlayer(); media.setAudioStreamType(AudioManager.STREAM_MUSIC); // Authdata String username = "username"; String password = "password"; // encrypt Authdata byte[] toEncrypt =

MediaPlayer prepare Failed Error(1,-17) when using recorded file .3gp

走远了吗. 提交于 2019-12-20 04:17:22
问题 I am trying record from the AudioRecorder then I am trying to play the same with Media Player, But its giving mediaplayer.prepare() failed to prepare. Could any one tell me what could appropriate reason. Below is the code I am using public void onClick(View v) { recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); if(case_value==0)

Mediaplayer and delay in playing

人走茶凉 提交于 2019-12-19 10:52:45
问题 I create small application which is media player. I have method where I have a song. I want to delay playing sound after I clicked a button. How I can do this delay. I want to click on the button and after 5 seconds music is playing. I am using: MediaPlayer.create to get song and mediaplayer.start() to start playing, but I don;t know how I can delay start playing my song. 回答1: Use a Handler in your Activity to delay events such as starting the mediaplayer in your case: private RefreshHandler

Android media player returns IllegalStateException

安稳与你 提交于 2019-12-19 05:58:19
问题 I have following code to play small audio files private void playVoice() { if (mPlayVoice != null) { if (mPlayVoice.isPlaying()) { mPlayVoice.release(); mPlayVoice = null; } } mPlayVoice = MediaPlayer.create(BirdsActivity.this, mSoundIds[getCurrentIndex()]); mPlayVoice.start(); } It works fine in Samsung galaxy tab but gives below error in small device(I Checked in Sony xperia mini pro my project) 08-17 12:45:45.232: ERROR/AndroidRuntime(6639): java.lang.IllegalStateException 08-17 12:45:45

Android Media Player Plays In The Background, But Doesn't Stop When App Killed

若如初见. 提交于 2019-12-19 05:06:40
问题 I'm new to Android, so I have a problem. In Android I want to play background music as soon as my music player starts and have it continue even if the activity changes from one to another. I've tried this code: MediaPlayer music = MediaPlayer.create(MainActivity.this, R.drawable.bgscore); music.start(); However, the sound should stop when user closes the app, and it doesn't. How can I achieve this? 回答1: Create a separate class for handling several conditions import android.content.Context;

Android- listview, service mediaplayer, and boolean flags

半腔热情 提交于 2019-12-19 04:46:27
问题 I currently have a listview and when you click on an item it runs a service with a mediaplayer . If I click on another item in the listview the service that's running should stop and run the new service . I am using a boolean isRunning set to false and when the service is created it returns true. Then in the listview I call that flag in an if statement. However, its not exactly working. I think I may be doing this wrong. Any ideas? This probably sounds confusing the way I described it so Here

iOS: How to save a video in your directory and play it afterwards?

江枫思渺然 提交于 2019-12-19 03:41:41
问题 I am working in an iOS project. I want may application to download a video from the internet programmatically . Then I want to play it. I know how can I play a local video from the Resources , but my question is how could I download it , and the find it to be played. I am using MPMoviePlayerController to run the video. Thanking in advance 回答1: I found the answer here I saved the video NSString *stringURL = @"http://videoURL"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData =

Headphone Jack Listener Android

天大地大妈咪最大 提交于 2019-12-19 02:48:28
问题 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? 回答1: 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

How to play multiple .wav files simultaneously in delphi

僤鯓⒐⒋嵵緔 提交于 2019-12-18 17:55:24
问题 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? 回答1: 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,