android mediaRecorder.setAudioSource failed
Open “AndroidManifest.xml” -> add <uses-permission android:name=”android.permission.RECORD_AUDIO” />
Open “AndroidManifest.xml” -> add <uses-permission android:name=”android.permission.RECORD_AUDIO” />
Before prepare(), you need first to call setDataSource(..). The Media framework is a very strict state machine, and it’s really cumbersome to handle all the different states. I’ve used this little wrapper that makes the coding/debugging a bit easier. You can give it a try. Regarding emulator – note that not all file formats are … Read more
Simply you can use MediaPlayer and play the audio file. Check out this nice example for playing Audio: public void audioPlayer(String path, String fileName){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(path + File.separator + fileName); mp.prepare(); mp.start(); } catch (Exception e) { e.printStackTrace(); } }
So I found this sample and it works for me, here it is if you have the same issue: in myMain.java import android.app.Activity; import android.os.Bundle; import java.io.IOException; import android.media.MediaPlayer; import android.media.MediaPlayer.OnBufferingUpdateListener; import android.media.MediaPlayer.OnPreparedListener; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ProgressBar; public class myMain extends Activity implements OnClickListener { private ProgressBar playSeekBar; private … Read more
When starting the activity i.e on onCreate put the following code. public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MediaPlayer mPlayer = MediaPlayer.create(FakeCallScreen.this, R.raw.mysoundfile); mPlayer.start(); } When stopping the activity i.e on onDestroy put the following code. public void onDestroy() { mPlayer.stop(); super.onDestroy(); } Hope it helps 🙂
I have solved this issues, just comment out this line fileName = [[fileName stringByAppendingString:@”-“] stringByAppendingString:[item valueForProperty:MPMediaItemPropertyArtist]]; because for some songs there is null artist so it’s crash……………….
Sound pool is actually audio mixer. It can play short clips only regardless of whether they are encoded as ogg or mp3 or they are uncompressed. Sound pool always store them in memory uncompressed, and you must know that limit is 1 MB. If your clip is too big in memory, sound pool will fall … Read more
I would like to tell you that MediaPlayer is running and working correctly. Below are all my hypothesis. Don’t take them too seriously. It is your test.m4a file that is encoded in a format such that MediaPlayer can’t decode, therefore throwing out an error saying that it can’t create the MediaPlayer for you to use. … Read more
use the style ?android:attr/progressBarStyleHorizontal for example: <ProgressBar android:id=”@+id/progressBar” style=”?android:attr/progressBarStyleHorizontal” and this is an example with MediaPlayer: package com.playerpgbar; import android.app.Activity; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.ProgressBar; import android.widget.TextView; public class Player extends Activity implements Runnable, OnClickListener { private TextView status; private ProgressBar progressBar; private Button startMedia; private Button stop; … Read more
JavaFX performs “hidden” initialization on start. Running MediaPlayer doesn’t trigger initialization. The easiest ways to trigger it are: have Application.launch() executed have Application based program being run from jar packaged by fx ant tasks (e.g. built from Netbeans JavaFX project) have JFXPanel started call Platform.startup(Runnable) (Java 9+)