android-mediaplayer

How to start(play) video once buffer reaches 20% in android video view

十年热恋 提交于 2020-01-02 04:11:11
问题 I have a video view to play video by using url which comes from server. I want video to be played once buffering reaches 20% . So i have added listener for setOnBufferingUpdateListener to mediaplayer like below. Uri video = Uri.parse(videoUrl); videoView.setVideoURI(video); videoView.requestFocus(); videoView.setOnPreparedListener(new OnPreparedListener() { public void onPrepared(MediaPlayer mp) { mp.setOnBufferingUpdateListener(Activity); progressVideoView.setVisibility(View.GONE); videoView

Android VideoView MediaPlayer OnInfoListener - events not fired

萝らか妹 提交于 2020-01-02 02:00:19
问题 this following source code snippet is given: videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mediaPlayer) { mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() { @Override public boolean onInfo(MediaPlayer mp, int what, int extra) { if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END){ activity.dismissDialog(DialogID.DIALOG_LOADING); return true; } return false; } }); } }); I am streaming HLS streams with Android 3.x+

State change listener for MediaPlayer

萝らか妹 提交于 2020-01-02 01:10:33
问题 In this diagram are lot of states: but with standard listener I can listen just some basic states. So is possible to listen every states changes for MediaPlayer? 回答1: Unfortunately I found no way of doing this other than surrounding the MediaPlayer with a custom state machine container. Added ... You could create a container that is a singleton and defines it's own states. And the only interaction with the MediaPlayer is done through this container. All other classes need to access the API of

How to access instance of MediaBrowserServiceCompat service?

岁酱吖の 提交于 2020-01-01 19:42:33
问题 I'm surprisingly struggling to get hold of the instance of a service which is derived from MediaBrowserServiceCompat . For a typical service, to achieve that, a local binder is used class MyService extends MediaBrowserServiceCompat { class MyBinder extends Binder { public MyService getService() { return MyService.this; } private final MyBinder binder = new MyBinder(); @Override public IBinder onBind(Intent intent) { return binder; } public void doMagic() { // <-- How to call this from

Generating a FileDescriptor on Android without first opening a file

◇◆丶佛笑我妖孽 提交于 2020-01-01 16:23:31
问题 In Android, is it possible to generate a FileDescriptor directly from a byte array, without having to open a file first? In Android 2.2, I am generating a MIDI file on the fly, and then playing it back using MediaPlayer. I've included the text of the Main.java file that does this successfully below. So far so good. However, this process first calls... FileOutputStream outputStream = openFileOutput(file, MODE_PRIVATE); outputStream.write(byteStream); outputStream.close(); ... to write out the

how to get bit rate , sampling rate and no. of channels of a audio file in android

和自甴很熟 提交于 2020-01-01 09:33:15
问题 I need your help for the below query: Query: Is there any way of getting following info of an audio file. Sample rate, Channel, Bitrate of an audio file. For extracting bitrate, "MediaMetadataRetriever" API is available (METADATA_KEY_BITRATE). Please suggest if it can be done using any android API. Found this below API, But its use is actually in different. http://developer.android.com/reference/android/medi/AudioTrack.html I want to extract these using Android API programmactically :

Get info about audio, playing in another application

限于喜欢 提交于 2020-01-01 03:46:28
问题 How can i get info about source (filedesc. or uri) from which another application playing audio? In AudioManager there is only isMusicActive() method, which doesn't give any additional information. And because of it isn't my application, i doesn't have any MediaPlayer object. 回答1: Register a broadcast receiver for known action intents and handle the broadcast to show or do something with the track information, source: public class CurrentMusicTrackInfoActivity extends Activity { public static

Android: How to stop other active media players?

本小妞迷上赌 提交于 2019-12-31 07:10:09
问题 I'm trying to create a music player. My application has 2 players - (a) plays songs from the memory (b) plays online music streams using URLs The home/default activity of my app is (a) . For player (b) there is a separate activity. Issue is when user presses the play button in activity (b) to play the URL stream, the track from the memory gets played. It seems like MediaPlayer from activity (a) is still active. So I want: If user presses the play button, all other media player gets stopped.

Why does it take longer for some internet audio streams to start playing on a Samsung S3?

两盒软妹~` 提交于 2019-12-31 01:06:39
问题 We are experiencing almost the exact opposite of what is mentioned here: Why does it take so long for Android's MediaPlayer to prepare some live streams for playback? I've tested multiple streams but two in particular 1 - http://usa8-vn.mixstream.net:8138 - SampleRate: 32000Hz and Bitrate: 96 kb/s 2 - http://source01.platform02.true.nl:800 - SampleRate: 44100Hz and Bitrate: 128 kb/s The lower bitrate stream starts playing instantly (as soon as the media player is prepared ), while the higher

ANDROID_LOOP = true — how to avoid MediaPlayer looping audios with this metadata tag

夙愿已清 提交于 2019-12-30 18:50:13
问题 I want to play device ringtones with MediaPlayer yet it seems when the metadata tag ANDROID_LOOP = true is set MediaPlayer is ignoring the call of the method setLooping mMediaPlayer.setLooping(false); and loops the audio in any case. Also the onCompletionListener method is not called. I noticed that even audio apps like ES Media Player loop audios with this tag set to true regardless if looping is enabled or not. So my question is if I can make MediaPlayer ignoring this tag temporary modify