Matej Košút
Matej Košút

Reputation: 570

Android - m3u8 video streaming

I am streaming live video in my app. I have a .m3u8 link, which works perfectly in vlc player. But when I am playing this stream in my app, the visualisation of video is damaged (see screenshot). Does anybody know, what could cause this?damaged video

EDIT: I realised that this occurs only on the Android 8.1.

Upvotes: 4

Views: 2610

Answers (2)

Hossin Asaadi
Hossin Asaadi

Reputation: 405

if you use android studio can impalement NiceVieoPlayer library , it powerfull and load on all devices. you can stream live with it.

its some Chineses :D

goodluck.

Upvotes: 0

Ejaz Ahmad
Ejaz Ahmad

Reputation: 644

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();
}

Upvotes: 4

Related Questions