media-player

Android, should I make MediaPlayer a service?

梦想与她 提交于 2019-12-02 11:43:38
问题 I'm trying to write an Android application which will allow users to listen to a radio station. I have got the start and stop buttons to work and it plays the stream. If I press the home key and start doing other bits and pieces with the phone, the stream continues to play. This is how I want it to work. Should I bother creating a service to play the stream, or is the method I already use good enough? What benefit would having it in a service bring? A lot of tutorials and examples online seem

Can MediaPlaybackservice be used for getting information of currently playing audio file in android?

我的梦境 提交于 2019-12-02 10:42:20
I wrote a class which will handle the MediaPlaybackService in android. But the code is not working. My code for binding the serviceconnection is as follows: Intent in = new Intent(); in.setClassName("com.android.playerapps","com.android.playerapps.MediaPlayerServiceConnection"); ServiceConnection conn = new MediaPlayerServiceConnection(); ctx.bindService(in, conn, 0); ServiceConnection class is as follows: public class MediaPlayerServiceConnection implements ServiceConnection { IMediaPlaybackService mService; public void onServiceConnected(ComponentName name, IBinder service) { Log.i(

MediaPlayer() audio stuttering(android)

左心房为你撑大大i 提交于 2019-12-02 10:00:32
I am using the MediaPlayer function to stream a live audio stream from a remote server, in my android app. But the audio is choppy and stuttering. The problem is not my internet as the feed plays perfectly when I play it on the computer. What could be the problem?*Note: the streams are live. This is the code I'm using: MediaPlayer mp = new MediaPlayer(); try{ mp.setDataSource("http://radiotool:80/feed 342.mp3");//hardcoded for testing purposes mp.prepare(); mp.start(); } catch(Exception e) {Log.d("Error came up man",", check the internet connection and stuff.."); Brad The stream you are

MediaPlayer change DataSource Error when MediaPlayer complets Playing First Audio

孤街醉人 提交于 2019-12-02 09:28:01
Any one Help for MediaPlayer Error. when aim is to Change DataSource and Play second Audio when First Audio is Compliting its Playing. My Code is below :- mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(MediaPlayer arg0) { String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + FILENAME+arrListSize+".wav"; mMediaPlayer.release(); mMediaPlayer = null; mMediaPlayer = new MediaPlayer(); Uri uri = Uri.parse("file://"+fileName); mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mMediaPlayer.setDataSource

how can i get songs from my iphone's ipod to my application in array in iphone sdk?

孤者浪人 提交于 2019-12-02 08:12:26
can i store or just create a customize view which allow user to play songs within from my application when user clicks on songs at that time the iphone's iPod(MusicPlayer) picker should not open it just show all songs in my application in TableView or PickerView it allows user to select the songs within my created customized view that TableView or PickerView. i have also seen this example. but it just opens the music player picker view. did you get my point is this possible to do that within my application.? just similar like this question here i found link that tells use API 3.0 Yes Amergin

Audio is not playing after stop serviec in Media player

℡╲_俬逩灬. 提交于 2019-12-02 07:54:12
Guys I am working on Audio module in my app so i have created on simple Audio demo with service. Its working up to Play - Pause - Playing in Background but issue is strange. Simply while launch app i have added two Buttons like Play/Pause (Will change caption according state) stop (To stop service) Now as i said my play-pause & Stop are working perfectly but when i try to play again audio after the click on stop its cause the problem in Start Error : 05-01 13:37:42.671: E/start(8096): java.lang.IllegalStateException Reference Link for Media Player State Reference Link for play audio in

android:play audio files using single mediaplayer object and also display images

淺唱寂寞╮ 提交于 2019-12-02 07:36:13
i need to display images and play corresponding audio files one after the other. i tried to create multiple media player objects but it shows error(1, -17) so plz help guys i am running out of time. Right now i have a handler which plays audio file and then get the duration of that audio file while playing another audio file this is my approach but i am unable to play some 10 files below is my sample code img.setBackgroundResource(R.drawable.d002_p001); d002_ae_p001 = MediaPlayer.create(this, R.raw.d002_ae_p001); handler.postDelayed(new Runnable() { @Override public void run() { // TODO Auto

MediaPlayer prepare Failed Error(1,-17) when using recorded file .3gp

大城市里の小女人 提交于 2019-12-02 06:45:37
I am trying record from the AudioRecorder then I am trying to play the same with Media Player, But its giving mediaplayer.prepare() failed to prepare. Could any one tell me what could appropriate reason. Below is the code I am using public void onClick(View v) { recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); if(case_value==0) recorder.setOutputFile(deviceMIC_path); else if(case_value==1) recorder.setOutputFile(deviceMIC_Handset

Open MediaPlayer - event unhandled in Thread

南笙酒味 提交于 2019-12-02 04:53:11
I'm trying to create a media player (with Media.MediaPlayer() class) and for this I am using a thread to process the songs that are loaded by the user using the OpenFileDialog. I am using the next code to start the process the songs: public static List<MediaFile> MediaList = new List<MediaFile>(); public static Queue<String> MediaFilesQueue = new Queue<String>(); public static void AddMediaFilesToMediaList() { String pathToFile; while (MediaFilesQueue.Count > 0) // all the files are loaded into the Queue before processing { pathToFile = MediaFilesQueue.Dequeue(); MediaData.MediaList.Add(new

Can't play mp4 converted file - JavaFX 2.1

狂风中的少年 提交于 2019-12-02 04:31:15
I have converted my .mov video to .mp4 , but when I play the video in my javafx application, it doesn't work, I can hear the audio of the video file but without pictures ! maybe the .mp4 is not in the right codec! any idea or solution? UPDATE With the same code I have played another mp4 video, in the same conditions (plateforme, JFX Version, ...), so I'm concluding that I have problem with this mp4 converted file, ie the software that I'm using to convert the mov file doesn't generate the approriat mp4 format that is supported by JFX 2.1. The following code sample demonstrates playing an h.264