Home > Back-end >  playing video from url channel in android
playing video from url channel in android

Time:01-28

I want to play live tv channel in android app how we use live tv channel i use exoplayer but dosent work. Here is my code

try {
        String videoURL = "https://www.samaa.tv/live/";

        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));
        exoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
        Uri videouri = Uri.parse(videoURL);
        DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory("exoplayer_video");
        ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
        MediaSource mediaSource = new ExtractorMediaSource(videouri, dataSourceFactory, extractorsFactory, null, null);

        exoPlayerView.setPlayer(exoPlayer);
        exoPlayer.prepare(mediaSource);
        exoPlayer.setPlayWhenReady(true);

    } catch (Exception e) {
        Log.e("TAG", "Error : "   e.toString());
    }

CodePudding user response:

use official youtube api instead of exo player or other library.

add Webview to your app and use this GET https://www.googleapis.com/youtube/v3/videos to extract the videos or attach direct link to that api

heres the forum to youtube api and documentation https://developers.google.com/youtube/v3/docs/videos/list

CodePudding user response:

Try these links below in exoplayer

  • https://youtu.be/IH0Bmc2jRio
  • https://www.youtube.com/watch?v=IH0Bmc2jRio
  •  Tags:  
  • Related