android-mediaplayer

List installed media players

北慕城南 提交于 2020-02-06 05:29:37
问题 I'm trying to get a list of all apps that can handle media installed on Android. I've tried the methods listed here, but none of them worked. They all return an empty list and I have multiple media players installed, which are all recognized by Headset Droid (https://play.google.com/store/apps/details?id=tvk.headvol). Can anybody suggest any alternative method or might have and idea what the problem can be? Do I need to set any permissions? 回答1: Here is what I came up with: PackageManager

android audio - soundpool alternatives

馋奶兔 提交于 2020-02-06 05:07:05
问题 I like the Android Soundpool class for its simplicity and it works well with the standard audio files I am using in my app. Now I want to make it possible for the user to specify certains sounds by specifying audio files on the sd card. Unfortunately I run into limitations of Soundpool, when the sound file is too big i get a AudioFlinger could not create track. status: -12 response. It seems I have to switch to MediaPlayer yet before getting into the complexity of MediaPlayer again I wanted

android audio - soundpool alternatives

时光毁灭记忆、已成空白 提交于 2020-02-06 05:07:01
问题 I like the Android Soundpool class for its simplicity and it works well with the standard audio files I am using in my app. Now I want to make it possible for the user to specify certains sounds by specifying audio files on the sd card. Unfortunately I run into limitations of Soundpool, when the sound file is too big i get a AudioFlinger could not create track. status: -12 response. It seems I have to switch to MediaPlayer yet before getting into the complexity of MediaPlayer again I wanted

ExoPlayer and start / pause / seekTo commands

此生再无相见时 提交于 2020-01-28 18:12:30
问题 I am trying to use ExoPlayer , as opposed to MediaPlayer and I can't seem to figure it out... MediaPlayer has .start() / .pause() commands... and I can just seekTo(1287) and it automatically starts playing... How do I do this with ExoPlayer ? I have tried to do seekTo(1287) but it doesn't start playing after... I have also added .setPlayWhenReady(true) after that, and still no luck... I am able to .stop() ... but I can't get it to start playing again after that unless I .prepare() again...

How to display Now Playing Card on Android TV

一世执手 提交于 2020-01-26 01:54:08
问题 I am using MediaPlayer for playing audio in my android application. There are some troubles with displaying the Now Playing Card in Recommendation row on Leanback Launcher. I have extended MediaSessionCompat.Callback in the player. What am I doing wrong? (code is below). What is supposed to be done for this card to be displayed? private void createMediaSession() { if (mSession == null) { mSession = new MediaSessionCompat(mContext, "MediaSession"); mSession.setCallback(this); mSession.setFlags

Mediaplayer looping stops with an error Android

天涯浪子 提交于 2020-01-25 11:03:47
问题 // Will need this in the callbacks final AssetFileDescriptor afd = getResources().openRawResourceFd(R.raw.sample); // Build and start first player final MediaPlayer player1 = MediaPlayer.create(this, R.raw.sample); player1.start(); // Ready second player final MediaPlayer player2 = MediaPlayer.create(this, R.raw.sample); player1.setNextMediaPlayer(player2); player1.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public void onCompletion(MediaPlayer mediaPlayer) { //

Why doesn't MediaPlayer.seekTo(t) go to the exact specified instant “t”?

允我心安 提交于 2020-01-24 08:26:08
问题 I'm trying to get the media player to play a specific range in a locally stored video. It doesn't seem to start at the specified time I tell it to. Example: when I seek to 1000, it works. But when I seek to 1500, it goes to 2000 instead. I also tried pausing seeking then starting on seek completion, it doesn't make any difference. This is the code: mediaPlayer.start(); mediaPlayer.seekTo(time); Is this normal? Or am I using the media player the wrong way? 回答1: This is an encoding issue.

Why doesn't MediaPlayer.seekTo(t) go to the exact specified instant “t”?

痴心易碎 提交于 2020-01-24 08:26:01
问题 I'm trying to get the media player to play a specific range in a locally stored video. It doesn't seem to start at the specified time I tell it to. Example: when I seek to 1000, it works. But when I seek to 1500, it goes to 2000 instead. I also tried pausing seeking then starting on seek completion, it doesn't make any difference. This is the code: mediaPlayer.start(); mediaPlayer.seekTo(time); Is this normal? Or am I using the media player the wrong way? 回答1: This is an encoding issue.

Android - Play SoundFont with MIDI file

南楼画角 提交于 2020-01-22 14:43:12
问题 I have one midi file and I have played that midi file using MediaPlayer in android using the following code: val mMediaPlayer = MediaPlayer.create(context, R.raw.test_ring_1) mMediaPlayer?.start() It default play with one instrument like piano, now I want to add soundfont (sf2/sf3) file to play the midi notes with different instrument and with reverberation effects. Please guide a way to achieve expected result. 回答1: There are two libraries that will be used to play a midi file using

Android - Play SoundFont with MIDI file

冷暖自知 提交于 2020-01-22 14:37:25
问题 I have one midi file and I have played that midi file using MediaPlayer in android using the following code: val mMediaPlayer = MediaPlayer.create(context, R.raw.test_ring_1) mMediaPlayer?.start() It default play with one instrument like piano, now I want to add soundfont (sf2/sf3) file to play the midi notes with different instrument and with reverberation effects. Please guide a way to achieve expected result. 回答1: There are two libraries that will be used to play a midi file using