android-mediaplayer

How to add Subtitles(.SRT files) to video in Exoplayer android?

萝らか妹 提交于 2019-12-18 12:32:32
问题 i am working on a project where i should play .srt files along with video in android. I was working through the samples of Exoplayer but cant able to play .srt files with video. The code i used is, MediaSource mediaSource = new HlsMediaSource(Uri.parse("https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8"), mediaDataSourceFactory, mainHandler, null); Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP, null, Format.NO_VALUE, Format.NO_VALUE, "en",

MediaPlayer Service Android

梦想与她 提交于 2019-12-18 11:52:54
问题 I am new to Android. I am creating service for Media Player so that it can continue to play song even if i close the application. I have created activity for Media Player and it is having all the functionality like play , pause , next , previous , seekbar and also includes oncompletionlistener . All works excellent. But Now i want that all should be managed by service. I have Created MyService Class : public class MyService extends Service { public static MediaPlayer mp; @Override public

MediaPlayer Service Android

风格不统一 提交于 2019-12-18 11:52:26
问题 I am new to Android. I am creating service for Media Player so that it can continue to play song even if i close the application. I have created activity for Media Player and it is having all the functionality like play , pause , next , previous , seekbar and also includes oncompletionlistener . All works excellent. But Now i want that all should be managed by service. I have Created MyService Class : public class MyService extends Service { public static MediaPlayer mp; @Override public

IllegalStateException for MediaPlayer.prepareAsync

ぐ巨炮叔叔 提交于 2019-12-18 11:41:58
问题 05-19 11:52:51.622: ERROR/MediaPlayer(1291): prepareAsync called in state 8 05-19 11:52:51.622: WARN/System.err(1291): java.lang.IllegalStateException try { mp = MediaPlayer.create( Main.this, Uri.parse("http://codejanitor.us/good.mp3")); mp.setOnPreparedListener(new OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mp.start(); } }); try { mp.prepareAsync(); } catch (IllegalStateException e) { e.printStackTrace(); } } finally { if (mp != null) { mp.release(); mp = null

Complete list of MediaPlayer error codes

眉间皱痕 提交于 2019-12-18 10:41:37
问题 I'm implementing a MediaPlayer . Everything goes smoothly BUT each time I encounter a new error it can be very hard to find its meaning. The official doc is lacking in that area, so a website like stack overflow is the only solution and this time even this does not work (error (1;-107) btw). So is there a centralized point where I can find the list of all the MediaPlayer error codes ? I can't find it in the official documentation, and it would be tremendously helpful to quickly diagnose new

Android: Keep MediaPlayer running during Activity screen orientation update

北城余情 提交于 2019-12-18 04:46:20
问题 I use a MediaPlayer to play an MP3. Currently I disabled screen orientation changes by using android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation" in the manifest. I do want to support landscape mode now - i.e. removed those tags - but have the problem that during the destroy/create cycle the player gets stopped and then restarted. This is okay and I actually do this even manually in onPause() to stop the player when the activity goes in the background. To

Play media files located in assets folder

倾然丶 夕夏残阳落幕 提交于 2019-12-18 03:46:24
问题 I currently have a set of media files in the raw folder of the android project that are loaded quickly and played when called using the mediaplayer class. I need to add more variations of these files and categorize them into folders, but apparently the raw folder does not support folders. Would I be able to quickly load these files from the assets folder and play them with mediaplayer? If so, how? 回答1: I've this method that returns the all files by extension in a folder inside asset folder:

Play media files located in assets folder

爷,独闯天下 提交于 2019-12-18 03:45:04
问题 I currently have a set of media files in the raw folder of the android project that are loaded quickly and played when called using the mediaplayer class. I need to add more variations of these files and categorize them into folders, but apparently the raw folder does not support folders. Would I be able to quickly load these files from the assets folder and play them with mediaplayer? If so, how? 回答1: I've this method that returns the all files by extension in a folder inside asset folder:

Android SDK - Media Player Video from URL

纵饮孤独 提交于 2019-12-18 02:42:33
问题 I've tried to find a simple tutorial which explains how to load a video from a URL into the android media player but unfortunately I couldn't find any! I have tried several things to try get it working but still no luck. What is the best way to have a MediaPlayerActivity just load a video from a URL? Thanks EDIT: I have tried the following code as suggested: VideoView videoView = (VideoView) findViewById(R.id.your_video_view); MediaController mediaController = new MediaController(this);

How to solve NullPointerException error in Android?

我与影子孤独终老i 提交于 2019-12-17 20:50:57
问题 The below code runs smoothly in the emulator from Eclipse, but there are problems when I run it on my Android phone and tablet. public class RingerActivity extends Activity{ /** Called when the activity is first created. */ Button press; boolean tone = true; MediaPlayer mp; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mp = new MediaPlayer(); mp = MediaPlayer.create(RingerActivity.this, R.raw.alarm); //Error