android-mediaplayer

How to get hardware key option to center of screen

有些话、适合烂在心里 提交于 2019-12-25 14:48:55
问题 How to get the pause play forward button option to center of the screen in MediaPlayer but by default it shows at the bottom of the screen. Here I am using videoView in fullscreen XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" <VideoView android:id="@+id/media_video_preview" android:layout_width="match_parent" android:layout_height="match

How to get hardware key option to center of screen

假如想象 提交于 2019-12-25 14:48:28
问题 How to get the pause play forward button option to center of the screen in MediaPlayer but by default it shows at the bottom of the screen. Here I am using videoView in fullscreen XML: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" <VideoView android:id="@+id/media_video_preview" android:layout_width="match_parent" android:layout_height="match

The play sound does not work when rotate the mobile

a 夏天 提交于 2019-12-25 11:17:19
问题 I have my project to play sound. It worked well but when I rotate the mobile the sound doesn't work also it worked well when the app start. Also there isn't any error. @JavascriptInterface public void playsound(String value ) { if (value.equals("on")) { mp= MediaPlayer.create(mContext,R.raw.sound); mp.start(); } else { mp.stop(); } } 回答1: When your device is rotated, the current Activity gets recreated. You likely need to hook into the Activity lifecycle events in order to properly manage the

Android: replace sound of onclick

拥有回忆 提交于 2019-12-25 06:38:21
问题 I have this code: Button boton = (Button) findViewById(R.id.boton); boton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); when I push my button (in Android 4.0.3) I ear a basic sound (a simply click); Can I replace it with a personal sound? Or I can use only MediaPlayer to play a costum sound? 回答1: Try this: public class MyActivity extends Activity { public MyActivity(Bundle onSavedStateInstance) { MediaPlayer mp = MediaPlayer.create(this, R.raw

Resume song in Android

↘锁芯ラ 提交于 2019-12-25 05:45:09
问题 I have created a media player . I run the application properly. But I want to resume my song when I restart my activity. Why does my audio restart when I restart my activity? How can I do this? I don't understand. Can any one help me?? Here is my code. public class Audio_Activity extends Activity { public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.audio); init(); mp=MediaPlayer.create(Audio_Activity.this,R.raw.ennamo_yadho); Log.e(

Passing arraylist from multiple fragments to activity

為{幸葍}努か 提交于 2019-12-25 04:22:55
问题 I have a follow up question from my previous questions. My app starts and fragment loads, it passes in the arraylist correctly using interface and listener method .. Now when I click on navigation button to replace current fragment with another fragment... That fragment is exactly the same as first fragment but with different array list... How would I update the arraylist in activity? I get a classcast exception. Here are how both of my fragments are implemented Pass Arraylist from fragment

Display Media files in ListView, NullPointerException?

ぐ巨炮叔叔 提交于 2019-12-25 04:19:17
问题 MainActivity public class MainActivity extends Activity { /** Called when the activity is first created. */ private List<String> myList; File file; @Override public void onCreate(Bundle savedInstanceState) { Log.i("MEDIA", "A"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i("MEDIA", "B"); ListView listView = (ListView) findViewById(R.id.listView1); myList = new ArrayList<String>(); Log.i("MEDIA", "C"); File directory = Environment

Not able to run grep command

瘦欲@ 提交于 2019-12-25 04:16:06
问题 I was trying to run the following instruction, Process p = Runtime.getRuntime().exec("/system/bin/lsof|grep mediaserver"); In android(java) but I am getting error. if I run following instruction, Process p = Runtime.getRuntime().exec("/system/bin/lsof "); the file is successfully saved.Can anyone tell what is the error? Actually I want to list and check if media server service is being running or not. 回答1: The grep utility may not be installed on your device. You can check it by trying the

Play wav / mp3 output from TTS with mediacontroller

早过忘川 提交于 2019-12-25 03:09:05
问题 I am trying to output an MP3 or wav from TTS in android which then plays back via mediaplayer. The TTS output to file works well and the mp3 file is available on the sdcard at the following location: /sdcard/tmp/tmp.mp3 The problem I have is the audio file will only play once, if the user reselects the "Play" button then the file doesnt play. The second problem I have is that the media controller isnt showing while the file is playing / user touches the screen. The important parts of the code

Saving audio content Uri in sharedpreference to play later

雨燕双飞 提交于 2019-12-25 02:09:16
问题 I am trying to design an Alarm app where Audio is played when the device is shaken. I am selecting the Audio from file system using "ACTION_GET_CONTENT" in Intent with ActivityForResult . I am able to fetch the content uri , saving it in SharedPreference and playing it with MediaPlayer on a different Activity passing the URI in Intent . But, once I close my app and reopen it and try to play the Audio from the URI in SharedPrederence , the Audio is not played. What can be done so that I can