media-player

Android - How to tell when MediaPlayer is buffering

纵饮孤独 提交于 2019-11-28 18:41:02
问题 I've got to be missing something obvious here, but I can't seem to find anything to allow me to determine when MediaPlayer is buffering audio. I'm streaming internet audio and I want to display a buffering indicator, but nothing I've tried allows me to know when MediaPlayer interrupts the audio to buffer, so I can't properly display a buffering indicator. Any clues? 回答1: @Daniel, per your comment on @JRL's answer, you could probably get this working by spinning up a thread and waiting for a

Android: How to create video player?

你离开我真会死。 提交于 2019-11-28 18:28:44
I am creating a video recorder and would like to create video player to preview the recorded videos. Modifying the code from this page I have created a MediaPreview class the following way: public class MediaPreview extends Activity implements OnErrorListener, OnBufferingUpdateListener, OnCompletionListener, OnPreparedListener, SurfaceHolder.Callback{ private static final String TAG = "MediaPreview"; private MediaPlayer mp; private SurfaceView mPreview; private SurfaceHolder holder; private Button btnPlay; private Button btnPause; private Button btnReset; private Button btnStop; private String

How to implement an audio player for Android using MediaPlayer And MediaController?

巧了我就是萌 提交于 2019-11-28 17:07:17
I want to create an Android application that is a client for an Internet radio station. And I want it look native to Android? But im confused with Android API logic and documentation. What i've got is that I need MediaPlayer and MediaController classes. Am I right, and is there any good example of AUDIO player for Android? Especially, I'm very interested how to use MediaPlayer and MediaController classes together. UPD: Finally I've got the code, that does exactly what I want: Intent i = new Intent(Intent.ACTION_VIEW); Uri u = Uri.parse(%file_uri%)); i.setData(u); startActivity(i); you can look

AVPlayer HLS live stream level meter (Display FFT Data)

时光怂恿深爱的人放手 提交于 2019-11-28 16:48:05
I'm using AVPlayer for a radio app using HTTP live streaming. Now I want to implement a level meter for that audio stream. The very best would a level meter showing the different frequencies, but a simple left / right solution would be a great starting point. I found several examples using AVAudioPlayer . But I cannot find a solution for getting the required informations off AVPlayer . Can someone think of a solution for my problem? EDIT I want to create something like this (but nicer) EDIT II One suggestion was to use MTAudioProcessingTap to get the raw audio data. The examples I could find

Android: MediaPlayer gapless or seamless Video Playing

天涯浪子 提交于 2019-11-28 16:43:42
I can play the videos fine back to back by implementing the OnCompletionListener to set the data source to a different file. No problems there. I call reset() and prepare() just fine. What I haven't been able to figure out, is how to get rid of the 1-2 second gap screen flicker between the data source change and the new video starting. The gap shows a black screen, and I haven't found any way to get around it. I've tried setting the background of the parent view to an image, but it manages to bypass that. Even if the SurfaceView is transparent (which it is by default.) I've also tried to have

java.lang.IllegalStateException what does it mean?

烂漫一生 提交于 2019-11-28 16:33:54
I'm developing a video application. After 1st video playback done, in the "OnCopletion" I'm trying to start a new one. But it just stops (not crashes) and do nothing. In the log: 10-19 09:44:49.056: ERROR/MediaPlayer(4654): setDataSource called in state 128 10-19 09:44:49.056: WARN/System.err(4654): java.lang.IllegalStateException 10-19 09:44:49.056: WARN/System.err(4654): at android.media.MediaPlayer.setDataSource(Native Method) 10-19 09:44:49.056: WARN/System.err(4654): at ru.osiris.BusAdvertising.BusAdvertisingActivity.onCompletion(BusAdvertisingActivity.java:1255) 10-19 09:44:49.056: WARN

How to resume playing after paused using gstreamer?

你。 提交于 2019-11-28 14:33:24
I've written C++ wrapper for each Gstreamer types. They're simple and intuitive, so I don't think their implementation needs to be posted here (though I could post them (maybe at github) if need arises). The problem I'm facing is that I start playing a video (and simulteneously saving it to a file using gst tee element)....and while it is playing, I pause (from different thread) which is working great. However, when I want to resume it, it doesn't work: void pause() { _pipeline.state(GST_STATE_PAUSED) } void resume() { _pipeline.state(GST_STATE_PLAYING); } And here is the play() function where

Modifying FileInputStream for mediaPlayer setDataSource

自作多情 提交于 2019-11-28 14:06:53
I'm trying to modify (extend) the FileInputStream class so that I can open an encrypted file and use the stream for MediaPlayer's setDataSource(FileDescriptor) . Problem is I don't know which method should be overridden to do the decryption inside the stream. I tried overriding all the read() methods, but the mediaPlayer doesn't seem to use them. Any suggestions? Pointer Null I don't think that MediaPlayer accepts any kind of InputStream. You can't modify data read from file that are used in MediaPlayer. MediaPlayer accepts FileDescriptor (processed in native code as reads from real file, no

NullPointerException while using Android's mediaplayer

半腔热情 提交于 2019-11-28 13:11:55
I have two button and it will play a sound to notify about right choice, or wrong one. This is how I do it: MediaPlayer playError = MediaPlayer.create(QuizActivity.this, R.raw.error); playError.start(); Same with correct sound. It works fine most of the time, but when I click it many times, at random times I get this error: Basically it says line playError.start(); gives me NullPointerException (only sometimes) 07-21 23:05:32.767: ERROR/PlayerDriver(1287): Command PLAYER_PREPARE completed with an error or info PVMFErrResource, -17 07-21 23:05:32.767: ERROR/MediaPlayer(14449): error (1, -17) 07

How to control volume in android?

天大地大妈咪最大 提交于 2019-11-28 12:35:02
Android has the Hardware button for controlling volume (increase/decrease). I want to same functionality by using buttons in my application with visual volume control and it should be disappeared after some time (in sec). You need to use the AudioManager class. Developer doc is here . Depending on which volume you want to adjust (ringer/media) you may need to change the audiomode via AudioManager . Finally, to make the buttons disappear just use View.GONE on them. I would create a Runnable in the onClickListener and use a postDelayed to make the View disappear. 来源: https://stackoverflow.com