media-player

How to prevent mediaplayer to stop when screen goes off?

微笑、不失礼 提交于 2019-12-03 16:08:31
I have a mediaplayer in a Music class that is called from another secondary Activity . It works fine. But when screen goes off (either by timeout or button), the music stops playing, and when coming back and try to close the activity the program goes to "App Not Responding", because an IllegalStateException at a query like mediaplayer.isPlaying() . How can I prevent the mediaplayer to stop when screen goes off? Does it have to be through a service?? Assuming that the answer is yes, I tried to convert the Music class into a service (see below). I also added <service android:enabled="true"

VideoVideo - Video Width x Height- MediaPlayer Issue

自作多情 提交于 2019-12-03 16:03:07
I have written a sample app that reproduces the problem: https://github.com/blundell/VideoRatioProblemPerDevice The VideoView documentation states: Displays a video file. ... takes care of computing its measurement from the video so that it can be used in any layout manager, and provides various display options such as scaling The problem is the Samsung Galaxy S3 is doing weird things to the video and not respecting the ratio of the video. (also happening on an HTC device). Activity with full screen fragment: What I have found is when the video is played on the Samsung Galaxy S3 it will play

Pause/Stop MediaPlayer Android at given time programmatically

我是研究僧i 提交于 2019-12-03 14:48:31
I researched a little bit, but couldn't find any solutions to this problem: I would like to play a MediaPlayer and pause/stop it at a given time.. (ie: play from second 6 to second 17). I know that I can set its starting point with seekTo() method, but can I pause/stop it from playing by setting an end point (of course, before reaching the file end limit)? There are different ways you could do this, here's one: int startFrom = 6000; int endAt = 11000; MediaPlayer mp; Runnable stopPlayerTask = new Runnable(){ @Override public void run() { mp.pause(); }}; @Override protected void onCreate(Bundle

OnCompletion listener with MediaPlayer

核能气质少年 提交于 2019-12-03 14:42:58
问题 How do i use the OnCompletion listener for some music? I would like to press a button to go to another activity that plays some music and then goes back when the music playback is finished. I allready coded the other stuff. I just cant figure out how to use the OnCompletion listener? 回答1: You should put the code that should be run when the music is completed in the OnCompletionListener , for example: mPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void

How to stop MediaPlayer stream and then restart it? Android

帅比萌擦擦* 提交于 2019-12-03 14:21:12
I am making a simple app to play a online radio stream. I know how to set up the stream. Here is my code so far. It sets up the stream and plays it fine. But if I hit stop, I cannot get it to start again. Am I missing something obvious? final MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e

How play the video using “HTTP Live Streaming” in iphone?

半腔热情 提交于 2019-12-03 13:43:30
I am new to iphone development,I am parsing a XML URL and display its content in the table, when i click a row , its corresponding parsed tube URL is played using the movie player.I am using media player framework.Here is my code NSURL *movieURL = [NSURL URLWithString:requiredTubeUrl]; if (movieURL) { if ([movieURL scheme]) { MoviePlayerController *myMovie = [[MoviePlayerController alloc]init]; [myMovie initAndPlayMovie:movieURL]; } } This is working fine, but i want to play the video using "HTTP Live Streaming".How can i do that? Any tutorials and sample code would me more helpful.Thanks.

How to play radio live stream .asx video/x-ms-asf? [closed]

萝らか妹 提交于 2019-12-03 12:03:56
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . Is there any 3rd-party library in Android or Java that can play radio live stream? File extension: .asx MIME type: video/x-ms-asf

No Sound coming from Android Emulator

拥有回忆 提交于 2019-12-03 10:51:17
I ran my application and I can't get the sound working on the Android Emulator. I checked and enabled the audio playback boolean in the Eclipse AVD Manager. I also went into the sound options in the Android Emulator and put them up (no sound while putting them up). I checked the box that says all selections will make a noise(still no sound). My application uses the MediaPlayer class and I am running win7 x64 if that has anything to do with it. Help is appreciated. Regis St-Gelais I have a similar issue and I posted a similar question some time ago. See my question for more information.

How to stream authenticated content with MediaPlayer on Android

江枫思渺然 提交于 2019-12-03 10:41:36
I've seen quite a few posts asking this question on SO but there doesn't seem to be a definitive answer (or at least an answer I like!) I've got content protected behind basic auth (username/password) -- I can download it fine using the various HTTP download clases but for the life of me I can't sort out how to tell media player to stream it (and provide the authentication). I saw one post that suggested it wasn't possible since the MediaPlayer is all native code and doesn't things like the Authenticator. There are plenty of examples of how to first download to a cached copy and then play that

iOS - Video not rotating only in iOS7 over iPhone?

喜欢而已 提交于 2019-12-03 10:34:07
What i have Done? I am playing videos in an extended class of MPMoviePlayerViewController and have implemented orientation functions as follows - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation { if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown){ return FALSE; } else{ return TRUE; } } - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [self setControlsPositions:toInterfaceOrientation]; } -(BOOL)shouldAutorotate { return YES; } What issue i am Facing? The