android-mediaplayer

Before play video ask about the video player to play

*爱你&永不变心* 提交于 2019-12-20 04:42:08
问题 I have an app that plays video from internet, it works fine when there´s only one video player (the default one) but when there are more it fails. So what I want to do is before play the video ask about the player to play. I found this post "android-list of installed media players" but even if I do PackageManager packageManager = getPackageManager(); to get the instance the app fails This is the code protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState);

Play sound continuously onTouch()

≡放荡痞女 提交于 2019-12-20 02:54:28
问题 I want to play a gun shot sound continuously by onTouch. I am doing this for automatic gun sounds. So i have problem with there is delay in sound looping. which does not give real automatic gun sound effect. My main point is there should no delay when sound is playing again and again. My code is. public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (event.getAction() == MotionEvent.ACTION_DOWN) { mediaPlayer = MediaPlayer.create(RipleFire.this, sounds

android mediaplayer - play ringtone one time

白昼怎懂夜的黑 提交于 2019-12-19 11:44:07
问题 I try to play a device ringtone one time with the MediaPlayer class (I have to use MediaPlayer as I use the ringtones together with other audio sources in my app) So i try the following to play a random ringtone yet I cant stop it looping, it keeps playing. Is it possible to play a ringtone only one time with MediaPlayer. Thanks try { RingtoneManager mRing = new RingtoneManager(RingtoneActivity.this); int mNumberOfRingtones = mRing.getCursor().getCount(); Uri mRingToneUri = mRing

Android: playing a song file using default music player

喜欢而已 提交于 2019-12-19 10:46:13
问题 Is there a way to play media with the default media player? I can do this with the following code: Intent intent = new Intent(Intent.ACTION_VIEW); MimeTypeMap mime = MimeTypeMap.getSingleton(); String type = mime.getMimeTypeFromExtension("mp3"); intent.setDataAndType(Uri.fromFile(new File(songPath.toString())), type); startActivity(intent); But this launches a player with less controls and can't be pushed to the background. Can I launch the player with the default media player? 回答1: Try the

Record/capture internal sound playback of Android app and export mp3?

坚强是说给别人听的谎言 提交于 2019-12-19 07:36:17
问题 Is it possible to record the internal sound generated by the app? My app allows you to create and play back musical sequences. soundPool.play(soundIds[i], 1f, 1f, 1, 0, Constants.TIME_RATE); I'd like to be able to record the sequence and export to mp3. I've looked into Audio Capture but setAudioSource (int audio_source) only seems to accept MIC recording. Thanks 回答1: No, there's no API for getting the audio output, even for your own app (actually that's not entirely true, because you can get

Why am I getting “Unsupported format” errors, reading H.264 encoded rtsp streams with the Android MediaPlayer?

拈花ヽ惹草 提交于 2019-12-19 05:51:57
问题 I am trying to show H.264 encoded rtsp video on an Android device. The stream is coming from a Raspberry Pi, using vlc to encode /dev/video1 which is a "Pi NoIR Camera Board". vlc-wrapper -vvv v4l2:///dev/video1 --v4l2-width $WIDTH --v4l2-height $HEIGHT --v4l2-fps ${FPS}.0 --v4l2-chroma h264 --no-audio --no-osd --sout "#rtp{sdp=rtsp://:8000/pi.sdp}" :demux=h264 > /tmp/vlc-wrapper.log 2>&1 I am using very minimal Android code right now: final MediaPlayer mediaPlayer = new MediaPlayer();

Android:Media Player difference between PrepareAsync() and Prepare()

我与影子孤独终老i 提交于 2019-12-19 05:23:28
问题 I wanted to implement basic media player functionality and was confused between PrepareAsync() and Prepare() method calls. Which one should be used if the audio file is in the raw folder . 回答1: The difference between those methods is basically in what thread they're executed. Prepare runs in the thread you call it (most frequently UI thread) and thus if it takes long time (buffering video from the Internet and such) it will block your UI thread and a user might get ANR. PrepareAsync runs in a

Android Oreo Notification Crashes System UI

£可爱£侵袭症+ 提交于 2019-12-18 14:47:15
问题 I've managed to get notifications working in older API's, but not Oreo. Creating the notification causes my app to still work fine (no messages in logcat), however SystemUI crashes and reboots in an endless cycle while the Activity is running. The is the error in logcat for the systemui process: java.lang.IllegalArgumentException: width and height must be > 0 My code: private void showPlayingNotification() { NotificationCompat.Builder builder = mNotificationUtils.getAndroidChannelNotification

Resize/Scaling down a YouTubePlayerFragment while video is playing

北慕城南 提交于 2019-12-18 13:38:29
问题 I am trying to replicate the video minimization in the Youtube app as shown here. In order to achieve this, I've tried using the Draggable Panel library. When I ran the sample, I noticed that the video does not scale but rather crops when minimized during playback. When the video is stopped (not paused) and displaying a thumbnail, the view scales as its supposed to. I read on another question that YouTubePlayerView is implemented with a SurfaceView. I also read in the docs that SurfaceView

Play list of mp3 file with MediaPlayer in Android

扶醉桌前 提交于 2019-12-18 12:36:14
问题 I have a problem to reproduce more than one mp3 file using MediaPlayer in Android. I'm able to reproduce one single file but I did not find nothing useful to reproduce different files one after the other. The code that now I use to reproduce one file is: public MediaPlayer mediaPlayer = null; public void playP(View view) { if (mediaPlayer == null) { mediaPlayer = MediaPlayer.create(MainActivity.this, R.raw.music); } mediaPlayer.start(); } How can I modify it to reproduce more a list of file?