android-mediaplayer

Check if Android MediaPlayer has been initialized

人盡茶涼 提交于 2019-12-11 03:56:52
问题 How does one check if a MediaPlayer object has been initialized? Is there something like a: MediaPlayer mp; if(mp.isInitialized()) Log.v("Test", "mp has been initialized. :D "); else Log.v("Test", "mp is NOT yet initialized. :( "); Of course, I checked the API Documentation and there isn't a method like that, but is there a similar approach? I'm considering just going through my code and just catching the thrown Exception if it ever triggers, but I find that unelegant. :P EDIT: My code was

Android TextureView OpenGLRenderer﹕ GL_INVALID_OPERATION

孤街浪徒 提交于 2019-12-11 03:38:25
问题 I have two fragments that has a TextureView to show camera preview or to play video. after using the app for a while, playing with the screens, i get this error in the logcat OpenGLRenderer﹕ GL_INVALID_OPERATION i release everything from my fragments, all members are set to null. @Override public void onDestroyView() { Logg.DEBUG(TAG, "onDestroyView"); super.onDestroyView(); if (mMediaPlayer != null) { mMediaPlayer.stop(); mMediaPlayer.release(); mMediaPlayer = null; } nextButton = null;

Updating Ui Components in Activity based on MediaPlayer object from Service While Playing music files in background

99封情书 提交于 2019-12-11 03:32:33
问题 I am creating an Android music player based on the tutorial from Android Hive here is the link. http://www.androidhive.info/2012/03/android-building-audio-player-tutorial/ Which is tutorial for creating an music player like this. Now I have successfully created my customized music player using this tutorial but their is a problem in that i.e. it doesn't play music in background. So searched for it and found this post Playing BG Music Across Activities in Android and I have found that I have

Mediaplayer prepare showing Illegal State Exception

随声附和 提交于 2019-12-11 02:08:27
问题 I am trying to play an audio file from the internal storage. The code I used is.. package com.abhi.firstapp.firstapp; import android.content.Context; import android.media.AudioManager; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.support.design.widget.FloatingActionButton; import android.support.design.widget.Snackbar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar;

How to stop media player sound when fragment not visible?

早过忘川 提交于 2019-12-11 01:58:10
问题 I have a slider fragments in my activity. I am trying to play a sound when the fragment is visible and stop the media player when the user slides to another fragment. Here's my code. I've tried implementing the method onHiddenChanged for the fragment but the sound keeps playing. public class WorkoutBuddyViewFragment extends Fragment { MediaPlayer mp; public WorkoutBuddyViewFragment() { } ImageButton play; TextView display; // BPPVComment#7: For now, this is a placeholder screen. // override

Audio focus client died with media player playing music in background

限于喜欢 提交于 2019-12-11 01:53:55
问题 I have created a music player which plays music through service, but after some time when i am outside the app music stops at random time, and i am getting the Log massage "Audio focus client died",i am not able to figure this out..why this is happening I am not attaching any code source because this is really a simple code that is not doing any complex task Just one service that playing music and one Audio focus helper which monitor the focus of audio.. 回答1: It may be because the Android OS

Over 10 seconds to load an audiostream with MediaPlayer on Samsung Galaxy S5 Android 5.0

被刻印的时光 ゝ 提交于 2019-12-11 01:52:52
问题 Since the update to Android 5.0 MediaPlayer does not work properly on the Samsung Galaxy S5. The loading time is over 10 seconds after you start an audio stream. Samplecode: MediaPlayer mPlayer new MediaPlayer(); String url = "http://149.13.0.80:80/radio1.ogg"; mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); mPlayer.setDataSource(url); mPlayer.prepare(); mPlayer.start(); Same problem if I use MediaPlayer in a service/with prepareAsync()/other audiostreams. Nexus 4 with Android 5 has

Sound Plays from Smarthpone Speakers instead Android Auto Speakers

喜你入骨 提交于 2019-12-11 00:47:24
问题 I am new to Android Auto and still trying to figure it out. I have successfully played music from my own programmed app but the music is coming out from my smartphone speakers instead of car speakers. Other (sample) apps do it the right way. Which part of of the Media System is responsible to handle this behaviour? Android documentation says the sound is sent to the car speakers. @Override public void onPlayFromMediaId(String mediaId, Bundle extras) { this.mPlayingQueue.add(item); session

Android- Mediaplayer streaming issue with test devices

扶醉桌前 提交于 2019-12-11 00:27:43
问题 I currently have a mediaplayer that is given a streamable datasource. I have two test devices: HTC Thunderbolt and a Samsung Galaxy SII Skyrocket. The HTC device is able to stream the files perfectly fine; however, the galaxy sII cannot at all, and gives me a bunch of media player error codes. I am implementing everything related to the media player properly...however, i can't get my head around this issue...how come it'll work on one phone but not the other? its the same link. Any ideas?

How to use .so file to create an .apk file in android application for my custom video codec

对着背影说爱祢 提交于 2019-12-10 22:32:25
问题 i want create an app or .apk file which can play video in particular format. For this I had compiled my source files and taken object files, from object files i have generated one shared library file (.so) using command gcc -c -fPIC hello.c -o hello.o gcc hello.o -shared -o libhello.so can somebody please help me with the steps to create apk file from .so file in android Eclipse or android sdk what is the importence of java files while creating an apk file... 回答1: From what you have put up