android-mediaplayer

How to avoid 15 second delay/caching in Android Media Player when playing stream

孤街浪徒 提交于 2019-12-09 10:05:30
问题 I am implementing a media player that plays a stream from a remote machine. Via my app I can control the remote machine (e.g. seek to second). Works like charm, but: The Android Media Player buffers some insane 10-15 seconds(!!), which means each click ('seek') takes 10-15 seconds to take effect even though it is less than a second until the new data arrives. My Question: Is there any way to control (limit) that caching? Or am I simply doing something wrong? Am I the only one having this

Android Recyclerview MediaPlayer previous Item sound stop, release after new one is clicked

…衆ロ難τιáo~ 提交于 2019-12-09 07:04:51
问题 In my app i have recyclerview items, and each item play sound when i click it. Problem is that when i click few items, they all play sounds in the same time until they finish. Lets say i click 10 items, all 10 play sounds in the same time and after some time app get crashed and i get this error: E/MediaPlayer: error (1, -19) . I avoid app crashing by implementing automatic release with this code: mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { @Override public

Get path of song from SD card in android

前提是你 提交于 2019-12-09 07:03:32
问题 In my android application I want to fetch song from SD card but I am not able to get the path of that particular file.I am using android api level 7 which doesn't support following method. Environment.getExternalStoragePublicDirectory (Environment.DIRECTORY_MUSIC); I have also tried following code : path = Environment.getExternalStorageDirectory(); but I don't know how to specify path of music file.Please suggest some solution.Thanx. 回答1: Get path and song Name from SD Card. You can find the

How to tell if .3gp file is audio or video in android

北慕城南 提交于 2019-12-09 07:03:26
问题 I have an app which allows user to import media (videos, photos, audio) which will then be managed by the application (as evidence). I've found that some audio recording apps will save audio in .3gp format (specifically Whats App messenger). If i get the mime type using the following code: MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension); it will come back as video/3gp which my app takes to mean it is of the type "video" and tries to make thumbnails and what not (I use the

How to make a simple VR video player by Google CardBoard Android SDK

ぐ巨炮叔叔 提交于 2019-12-09 06:52:28
问题 Im following as what Mog suggest in the post: How to create VR Video player using Google Cardboard SDK for Unity Here's my code snippet 1. In the MainActivity's onSurfaceCreated() method , I initialise a texture and bind it to GL, and create a surface and a mediaplayer associated to them. in the onNewFrame() method, I update the texture as what Mog said in the post I saved my short video as small.mp4 in the raw folder, however , after I start my app the two sides are blank, and the video's

Android Media Player RTSP

喜欢而已 提交于 2019-12-09 06:49:39
问题 I'm trying to watch RTSP streaming on Android device. But if the server set password for the streaming my Android cannot play it. If without password it's ok. Here is my codes. public class VideoFragment extends Fragment implements View.OnClickListener, SurfaceHolder.Callback, MediaPlayer.OnPreparedListener { VideoView m_videoView; SurfaceView m_surfaceView; SurfaceHolder m_surfaceHolder; MediaPlayer m_mediaPlayer; SharedPreferences m_sharedPref; Boolean m_videoStarted; public VideoFragment()

Android MediaMetadataRetriever returns null values from most keys

北城余情 提交于 2019-12-09 02:28:11
问题 I want to get information out of my media files (mp3 mostly) and I get only null from those values I want. I have tried all keys for extractMetadata(key) . Am I skipping/missing something? Code basis: MediaMetadataRetriever f = new MediaMetadataRetriever(); f.setDataSource(item.getFilePath()); String title = f.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); I do get correct values with the duration key (MediaMetadataRetriever.METADATA_KEY_DURATION) and mimetype key

Android MediaPlayer takes long time to prepare and buffer

倖福魔咒の 提交于 2019-12-08 22:46:27
问题 My application takes a long time to prepare and buffer an audio stream. I have read this question Why does it take so long for Android's MediaPlayer to prepare some live streams for playback?, however it just says people have experienced this issue, it does not state how to improve the problem. I am experiencing this in all versions of Android, tested from 2.2 - 4.1.2. The streams are in a suitable bit-rate for mobile and 3G connection. The same stream takes less than a second to start

How to play online radio streaming url in Android. How to play .pls radio streaming url in android

时光毁灭记忆、已成空白 提交于 2019-12-08 20:50:23
问题 I created a XML file in my server. It contains title and link tags. I fetch the tags and display them as links in ListView . From there when the user clicks the link, then I'd like play the .pls file in the Radio Station app. Here is my XML file: <item> <title> Kushi FM </title> <link>http://108.163.197.114:8071/listen.pls</link> </item> I don't know how to play the link in next activity. MainActivity : public class MainActivity extends AppCompatActivity { // All static variables static final

How do use a MediaPlayer to a SurfaceView in a Fragment

﹥>﹥吖頭↗ 提交于 2019-12-08 19:53:06
问题 Because I want to be able to pass the MediaPlayer that plays the video around, I want to use a SurfaceView instead of a VideoView inside my fragment that plays the video. I looked at an earlier question about how to attach the MediaPlayer to the SurfaceView. The answer to the question tells me to create two functions: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); getWindow().setFormat(PixelFormat