google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.74k stars 6.03k forks source link

Unsupported M3U playlist #8263

Closed Andreeiva closed 3 years ago

Andreeiva commented 3 years ago

I created an exoplayer activity that could play streams with m3u8 extensions. But i cant play a stream like this http://m3ulink.com:7899/gtZcA8Ugs/po5dA7Vm07/114000 Can you please help look into this ..thanks soo much `package com.drusoft.livefootballarena;

import android.content.pm.ActivityInfo; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.ImageView; import android.widget.ProgressBar;

import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity;

import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.ExoPlaybackException; import com.google.android.exoplayer2.ExoPlayerFactory; import com.google.android.exoplayer2.LoadControl; import com.google.android.exoplayer2.PlaybackParameters; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.Timeline; import com.google.android.exoplayer2.source.MediaSource; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.hls.HlsMediaSource; import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection; import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.ui.PlayerView; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter; import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;

public class VideoPlayerActivity extends AppCompatActivity {

private PlayerView videoPlayer;
private SimpleExoPlayer simpleExoPlayer;
private static final String FILE_URL = "";
ProgressBar progressBar;
ImageView btFullScreen;
boolean flag = false;
private Handler mainHandler;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_NO_TITLE);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_video_player);

    videoPlayer = findViewById(R.id.exo_player);
    progressBar = findViewById(R.id.progress_bar);
    btFullScreen = videoPlayer.findViewById(R.id.bt_fullscreen);
    setUpExoplayer(getIntent().getStringExtra("url"));
    simpleExoPlayer.addListener(new Player.EventListener() {
        @Override
        public void onTimelineChanged(Timeline timeline, @Nullable Object manifest, int reason) {

        }

        @Override
        public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {

        }

        @Override
        public void onLoadingChanged(boolean isLoading) {

        }

        @Override
        public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {

            if (playbackState == Player.STATE_BUFFERING) {

                progressBar.setVisibility(View.VISIBLE);

            } else if (playbackState == Player.STATE_READY) {

                progressBar.setVisibility(View.GONE);

            }
        }

        @Override
        public void onRepeatModeChanged(int repeatMode) {

        }

        @Override
        public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {

        }

        @Override
        public void onPlayerError(ExoPlaybackException error) {

        }

        @Override
        public void onPositionDiscontinuity(int reason) {

        }

        @Override
        public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {

        }

        @Override
        public void onSeekProcessed() {

        }
    });

    btFullScreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            if (flag) {

                btFullScreen.setImageDrawable(getResources().getDrawable(R.drawable.ic_fullscreen));
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                flag = false;
            } else {

                btFullScreen.setImageDrawable(getResources().getDrawable(R.drawable.ic_fullscreen_exit));

                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

                flag = true;
            }

        }
    });
}

private void setUpExoplayer(String url) {

    LoadControl loadControl = new DefaultLoadControl();

    DefaultBandwidthMeter defaultBandwidthMeter = new DefaultBandwidthMeter();

    TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory());

    simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
    videoPlayer.setPlayer(simpleExoPlayer);
    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,"LiveFootballArena");
    MediaSource mediaSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(url) );

    videoPlayer.setKeepScreenOn(true);
    simpleExoPlayer.prepare(mediaSource);
    simpleExoPlayer.setPlayWhenReady(true);
}

@Override
protected void onDestroy() {
    super.onDestroy();
    simpleExoPlayer.release();

}
@Override
protected void onPause() {
    super.onPause();
    simpleExoPlayer.setPlayWhenReady(true);

}

@Override
protected void onRestart() {
    super.onRestart();
    simpleExoPlayer.setPlayWhenReady(true);

}

}

`

AquilesCanta commented 3 years ago
curl -I http://m3ulink.com:7899/gtZcA8Ugs/po5dA7Vm07/114000

Yields HTTP 200, but the response is empty.

Trying to play http://m3ulink.com:7899/gtZcA8Ugs/po5dA7Vm07/114000 in ExoPlayer yields HTTP 410:

com.google.android.exoplayer2.upstream.HttpDataSource$InvalidResponseCodeException: Response code: 410

This doesn't seem like an ExoPlayer issue. Can you clarify?

Andreeiva commented 3 years ago

Hy thanks for your response the link actually expired a few hours ago Here's another link http://iptvstream.xyz:8080/test-6086c5/0fb3/157492 I tried it on an exoplayer demo app I downloader a few minutes ago. I was able to play the stream but it just buffers endlessly if i should parse same link into my exoplayer project. I will appreciate if you can look into this. Thanks soo much

AquilesCanta commented 3 years ago

The provided link is not valid. Please provide a valid stream. If you cannot forge a link which works, then please download the playlists and all corresponding segments and share that with me as a tar file. I cannot assist further until I have a way to reproduce the issue locally. Please don't provide expiring links.

$ curl http://iptvstream.xyz:8080/test-6086c5/0fb3/157492
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.14.0 (Ubuntu)</center>
</body>
</html>
Andreeiva commented 3 years ago

hy thanks for your response this is the link to thee playlist file http://dsud.site:25461/get.php?username=dvd247&password=dvd247m3u99&type=m3u if i should copy and paste on vlc it works hoping to hear from you

AquilesCanta commented 3 years ago

This is a duplicate of #4066. Please track #4066 for support of m3u playlists. Note that m3u playlists are not HLS streams. You should consider implementing a m3u playlist parser in your app. It should be straightforward, and you can pass the playlist items to the MediaItem API which will concatenate them for you.