media-player

MediaPlayer play audio in background and play next one

≯℡__Kan透↙ 提交于 2019-12-01 06:22:24
问题 I use below code to play audio in background: String[] Path = new String[] {path1, path2, ...}; mMediaPlayer.setDataSource(Path[i]); mMediaPlayer.prepare(); mMediaPlayer.start(); mMediaPlayer.seekTo(0); While I play the first one Path[0] in background. I want to make it auto play next one Path[1] after Path[0] play finish, how to arrive it? 回答1: You should override onCompletionListener like this, mMediaPlayer.setOnCompletionListener(new OnCompletionListener() { public void onCompletion

MediaPlayer instance: stop behaves like a pause

蓝咒 提交于 2019-12-01 05:45:58
I wrote a small music playback control test application. I have a play, pause, stop and rewind button. My issue is that that player.stop(); is behaving the same exact way as player.pause(); I am calling player.prepare() right after player.stop() so that i can have the player instance ready for start() operation. I do not see any errors [IOexceptions or IllegalStateExceptions] being raised while calling the prepare() after i do a stop(). Also, i am not calling any seekTo(0) after stop(). So, i am not setting the position back to the beginning of the song. I am using a Nexus Google One phone

AVPlayer Rotate View makes cannot tap to the screen

早过忘川 提交于 2019-12-01 05:26:23
问题 I used AVPlayer for movie player in my app. I explained the problem with diagrams. When I click Play button in movie view controller(Portrait mode),then goes to movie details view. When I tap on the screen , the navigation bar and movie player bar appear. If you tap again the screen, it will disappear. This goes well when the device is in Portrait mode. But, I changed my code to Landscape mode when I click on play button, it will automatically change to Landscape mode in movie details view.

How do I style the default Wordpress audio player with CSS?

泪湿孤枕 提交于 2019-12-01 05:10:43
问题 I frequently use the Wordpress audio shortcode to embed my podcast episodes in my posts: [audio src="http://podcastsourcefile"] Unfortunately, the default audio player looks terrible. I would like to have it restyled with CSS. I have a mockup I can send to show you what it should look like, but here's the basic gist: background color: #B27D47 replace play button image (I can provide the .png file) make the player 75 pixels tall, 100% width round the corners of the player Here's what I would

Android 4.2 with 4 MediaPlayers = “Can't play this video”

倾然丶 夕夏残阳落幕 提交于 2019-12-01 03:59:34
Whenever I'm trying to load at least 4 mediaPlayers, one of them will corrupt the video it's trying to load and trigger an Android OS message "Can't play this video" Other information: For 3 mediaPlayers everything works fine. On other Android versions, different from 4.2, the same code with the same 4 video works. The 4 video can be played independently on the device. There is no format problem. After starting the program and getting the "Can't play this video" message, the video can no longer be played in any other application unless I reset the device. I tried this both with VideoViews or

Android media player returns IllegalStateException

て烟熏妆下的殇ゞ 提交于 2019-12-01 03:35:22
I have following code to play small audio files private void playVoice() { if (mPlayVoice != null) { if (mPlayVoice.isPlaying()) { mPlayVoice.release(); mPlayVoice = null; } } mPlayVoice = MediaPlayer.create(BirdsActivity.this, mSoundIds[getCurrentIndex()]); mPlayVoice.start(); } It works fine in Samsung galaxy tab but gives below error in small device(I Checked in Sony xperia mini pro my project) 08-17 12:45:45.232: ERROR/AndroidRuntime(6639): java.lang.IllegalStateException 08-17 12:45:45.232: ERROR/AndroidRuntime(6639): at android.media.MediaPlayer.isPlaying(Native Method) 08-17 12:45:45

MediaPlayer instance: stop behaves like a pause

吃可爱长大的小学妹 提交于 2019-12-01 03:04:03
问题 I wrote a small music playback control test application. I have a play, pause, stop and rewind button. My issue is that that player.stop(); is behaving the same exact way as player.pause(); I am calling player.prepare() right after player.stop() so that i can have the player instance ready for start() operation. I do not see any errors [IOexceptions or IllegalStateExceptions] being raised while calling the prepare() after i do a stop(). Also, i am not calling any seekTo(0) after stop(). So, i

Android Media Player Plays In The Background, But Doesn't Stop When App Killed

我们两清 提交于 2019-12-01 02:18:07
I'm new to Android, so I have a problem. In Android I want to play background music as soon as my music player starts and have it continue even if the activity changes from one to another. I've tried this code: MediaPlayer music = MediaPlayer.create(MainActivity.this, R.drawable.bgscore); music.start(); However, the sound should stop when user closes the app, and it doesn't. How can I achieve this? Bhavna Create a separate class for handling several conditions import android.content.Context; import android.media.MediaPlayer; import android.util.Log; public class MusicManager { static final int

Select a music file to play with MediaPlayer

梦想的初衷 提交于 2019-12-01 00:37:27
I'm new in android programming and now i get a problem with my app. I intend to code a MediaPlayer application with feature: select a file from storage using intent then start playing that file. I use "MediaPlayer.create(context, uri)" method but currently i got error protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //openFile(); Button openFile = (Button) this.findViewById(R.id.ButtonOpen); openFile.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent chooseFile; Intent intent;

iOS: How to save a video in your directory and play it afterwards?

丶灬走出姿态 提交于 2019-11-30 22:33:11
I am working in an iOS project. I want may application to download a video from the internet programmatically . Then I want to play it. I know how can I play a local video from the Resources , but my question is how could I download it , and the find it to be played. I am using MPMoviePlayerController to run the video. Thanking in advance I found the answer here I saved the video NSString *stringURL = @"http://videoURL"; NSURL *url = [NSURL URLWithString:stringURL]; NSData *urlData = [NSData dataWithContentsOfURL:url]; NSString *documentsDirectory ; if ( urlData ) { NSArray *paths =