Play m3u8 video in android
The video was existed in http://www.livestream.com. In this there is Mobile Api for live streaming.
The Api is:
http://www.livestream.com/userguide/index.php?title=Mobile_API#How_to_get_mobile_compatible_clips_from_a_channel.27s_library
In above link there is full information for mobile compatible. To get the rtsp link from the channel to use this link
http://xproshowcasex.channel-api.livestream-api.com/2.0/getstream
Replace the your channel name instead of proshowcase
. And then get all mobile compatible url's like IPhone, Android, Blackberry etc.,
Using that url you can stream the video in Android by using video view or media player.
For more information please read the Mobile Api link.
If any one get the same problem I hope this answer will helps you.
Best of luck.
how to play m3u8 with exoplayer, the screen remains black
You need to use HLS media source to play m3u8 file.
use this
private MediaSource buildMediaSource(Uri uri) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "exoplayer-codelab");
return new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
}
instead of this
private MediaSource buildMediaSource(Uri uri) {
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, "exoplayer-codelab");
return new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
}
Any ideas on how can i stream m3u8 video in android
By m3u8 if you mean HLS videos, Google's ExoPlayer supports that. Also if you don't want to use ExoPlayer, android mediaplayer api has limited support for HLS stream from android 4.0.
I would suggest if you can spend some money on purchasing some thirdparty players, they'll give the best playabck experience and features. Refer the following players
- NexStreaming
- Akamai
- Brightcove
- JW Player - Its built on top of exoplayer
Exoplayer playing m3u8 files Android
On Android 4.1+, you can use this library https://github.com/brianwernick/ExoMedia/ . The example mentioned on the Read-me page should be sufficient to get you started. I have reproduced that code snippet with a few additions/modifications.
private void setupVideoView() {
EMVideoView emVideoView = (EMVideoView)findViewById(R.id.video_play_activity_video_view);
emVideoView.setOnPreparedListener(this);
//Enter your m3u8 URL below
emVideoView.setVideoURI(Uri.parse("http://SOMESERVER/playlist.m3u8"));
}
@Override
public void onPrepared(MediaPlayer mp) {
//Starts the video playback as soon as it is ready
emVideoView.start();
}
@Override
public void onPause() {
super.onPause();
//Pause Video Playback
emVideoView.pause();
}
How to Play M3U8 Format Android & iOS on Flutter
YoYo player is a great choice.
- Add dependency:
yoyo_player: #latest
- Use anywhere you want:
YoYoPlayer(
aspectRatio: 16 / 9,
url: "",
videoStyle: VideoStyle(),
videoLoadingStyle: VideoLoadingStyle(),
),
Android - m3u8 video streaming
Try this library for .m3u8 , this will solve your problem :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.devbrackets.android.exomedia.ui.widget.VideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:useDefaultControls="true"/>
</RelativeLayout>
In Activity write below code
private VideoView videoView;
private void setupVideoView() {
// Make sure to use the correct VideoView import
videoView = (VideoView)findViewById(R.id.video_view);
videoView.setOnPreparedListener(this);
//For now we just picked an arbitrary item to play
videoView.setVideoURI(Uri.parse("https://archive.org/download/Popeye_forPresident/Popeye_forPresident_512kb.m3u8"));
}
@Override
public void onPrepared() {
//Starts the video playback as soon as it is ready
videoView.start();
}
Related Topics
How to Get the Timezone Offset in Gmt(Like Gmt+7:00) from Android Device
Recyclerview Slow Scrolling Performance and Lag/Halt Sometime While Scrolling
How to Close All Activities and Exit from an App
How to Convert Android.Media.Image to Bitmap Object
Android Push Notifications Not Being Received When App Closed
How to Fix Attempt to Invoke Interface Method on a Null Object Reference
How to Start Android Application on Device Boot
How to Show the Number Keyboard on an Edittext in Android
Decrease Image Size Without Losing Its Quality in Android
Android Scrollview Not Scrolling Down After Keyboard Opens
Android Refresh a Fragment List from Its Parent Activity
How to Make Primary Key as Autoincrement for Room Persistence Lib
How to Set the Starting Position of a Scrollview
How to Use Adb With Emulator Like Memu/Bluestacks/Nox App Player
Unable to Add Window - Token Null Is Not Valid; Is Your Activity Running