android-mediaplayer

Multiple video players in viewpager in android

戏子无情 提交于 2019-12-07 04:47:00
问题 I want to play videos on different fragments in viewpager. I use multiple mediaplayers and surfaceviews for each fragment. When I swipe left or right, I want to pause and start videos as well. Swipe to next video has no problem at all but when i swipe to previous video(that is already playing) surfaceviews overlap. Meanwhile, I can play and pause videos without problem. I tried almost all possible combinations of setZorderMedia and setZOrderonTop but I failed. In short, the problem is that

MediaPlayer - java.io.FileNotFoundException: No content provider

帅比萌擦擦* 提交于 2019-12-07 04:01:30
问题 I've been writing an mp3 player for quite some time, but for some reason this exception: W/MediaPlayer: Couldn't open /storage/emulated/0/Music/generic music file.mp3: java.io.FileNotFoundException: No content provider: /storage/emulated/0/Music/generic music file.mp3 keeps popping up every time I try to play any song. The way I retrieve path to a song is: file.getAbsolutePath() where file is a File instance. And the way I play the song is: try { mediaPlayer = MediaPlayer.create(this, Uri

How to stop media player properly , android

家住魔仙堡 提交于 2019-12-07 01:29:10
问题 I have created a list of songs on click on the song i am able to play the song using MedaiPlayer. While one song is playing if the user clicks another song then i am stopping the media player and starting the player again. But I am getting illegalstateexception in reset(). Here is the code where I am getting the exception. How to stop a player properly? also why am i getting this exception. How to avoid it? public void stopPlayer() { try { if (player != null) { // Log.e("Trying to Stop ","

Should MediaPlayer.start() also be a new thread?

牧云@^-^@ 提交于 2019-12-07 00:44:06
问题 The tutorial here explains that a service actually uses the main thread. So it uses prepareAsync to avoid blocking UIS: http://developer.android.com/guide/topics/media/mediaplayer.html#asyncprepare I was wondering where the async callback onPrepared runs. In the example onPrepared calls start of MediaPlayer . Is start also a CPU-intensive method? If it runs in the same thread, it also blocks. 回答1: MediaPlayer.start() is not an intensive operation in the least. The MediaPlayer uses its own

Android Mediaplayer doesnt throw IO exception If file not available at the link

自作多情 提交于 2019-12-07 00:36:31
I am starting mediaplayer with a URL. The URL suppose to link to a video/Audio . But i have deleted the video/audio file from the location, hence i would like to expect a IOException id there is nothing available at that link. But i am not getting the IO exception. Instead mediaplayer itself try to go to the linkl 10 times and finally throw the error on onErrorListner. follwings are the logs printed while mediaPlayer is preparing. Note: - my url is not for local storaged file!! its for server side file. E/NuCachedSource2: source returned error -1, 10 retries left E/NuCachedSource2: source

setNextMediaPlayer not working

你。 提交于 2019-12-06 22:26:43
I am trying to find out how to use the android's MediaPlayer method setNextMediaPlayer which should smoothly transition from one player (song) to another. But do not know how to use the method since there is a lack of documentation. This is what i do and it does not work: final MediaPlayer mp1 = new MediaPlayer(); final MediaPlayer mp2 = new MediaPlayer(); try { mp1.setDataSource("http://song1.MP3"); mp2.setDataSource("http://song2.mp3"); mp1.prepareAsync(); mp1.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp1.start(); } }); mp1

Mediaplayer respond to second click to pause

限于喜欢 提交于 2019-12-06 18:43:18
问题 Used ViewPager for images sliding, each image onclick stream different MP3. app including 50 pages(images) & 50 different mp3, all mp3 stored on app itself. ex. First-page stream MP3(one), second-page stream MP3(two) and so on till page fifty. FIRST: its work fine just only one issue which is: In any page --> clicking the image --> PLAY MP3(one) --> click again--> PAUSE MP3 --> in paused state of MP3(one) SWIPE to next page --> --> in next page --> clicking the image --> PLAY MP3(two) -->

video & image viewPager

爱⌒轻易说出口 提交于 2019-12-06 18:12:26
I have a problem in my code can anyone help me? I need to make app play story like Messenger app I want to display a list of images and videos in viewpager automatically or manually I do it but I faced some problem First: when page of image is view and the next page play video the sound of video is playing when view the image because the pager load the next fragment i used mViewPager.setOffscreenPageLimit(0); but i didn't do any thing Second one: when I move manually from video to image the video not stop playing when I search for a solution I found this: public void setUserVisibleHint(boolean

Android MediaPlayer play m3u8 only audio streamming

孤街浪徒 提交于 2019-12-06 15:53:56
问题 Hi all and thanks in advance, After all day looking, searching and trying i do not know if it is even possible, or if the problem is in the code, or if the problem is in the server.... First of all, can MediaPlayer play a m3u8 file? In case Yes...it is only in versions greater than 3.0 or 4.0? if i just try to play the url in a real device 4.0.4 i get error (1,-1010) or error 100 or -214.... The code is simple: MediaPlayer mp = new MediaPlayer(); fich="http://devimages.apple.com/iphone

How to set volume in decibels using my android mobile application?

三世轮回 提交于 2019-12-06 15:35:05
I am working on a mobile app, where i need to play the sound file. On volume button press, i need to increase/decrease the volume through my app. I am using Media player to play and using SetVolume(left, right) function to set the volume. MediaPlayer mp; float left = 0.0f; float right = 0.6f; public void OnPlay(View v){ mp = MediaPlayer.create(this, R.raw.twofiftybeep); audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mp.start(); mp.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer mp) { // Playing the file continuously mp