Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exo player DASH Streaming example

I'm trying to play DASH video on android devices with the ExoPlayer from Google (http://developer.android.com/guide/topics/media/exoplayer.html). The documentation is very, very poor and I cannot find some simplest working example with DASH (if someone did it). In the video (https://www.youtube.com/watch?v=6VjF638VObA#t=462) it looks simple but in reality there is a lot of unknown objects. I want to use only ExoPlayer library and without using their github demo because it is very complex and I didn't find a way to add my testing URL because all samples are from YouTube.

Thanks

like image 815
Blagojco Avatar asked Feb 07 '15 19:02

Blagojco


People also ask

What is Dash ExoPlayer?

ExoPlayer supports features like Dynamic adaptive streaming over HTTP (DASH), SmoothStreaming and Common Encryption, which are not supported by MediaPlayer . It's designed to be easy to customize and extend.

Does YouTube use ExoPlayer?

Screenshot: The YouTube Android app, which uses ExoPlayer as its video player. ExoPlayer is an app-level media player built on top of low-level media APIs in Android. It is an open source project used by Google apps, including YouTube and Google TV.

How do I play a MPD stream?

You have to enter the URL of your MPEG-DASH stream (mpd file) and click on the big, yellow button for the player to play it back. THEOPlayer's demo player provides a bunch of useful information next to the video itself that is useful in keep track of the playback and debugging issues if they arise.


1 Answers

Here is a simple dash playing example which will play your stream content into SimpleExoPlayerView from exoplayer-ui.

Add SimpleExoPlayerView to your layout and use the code below

    SimpleExoPlayerView exoPlayerView = (SimpleExoPlayerView) findViewById(R.id.exo_player_view);

    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "ExoPlayer"));
    Uri uri = Uri.parse("http://your_host/dash/stream.mpd");
    DashMediaSource dashMediaSource = new DashMediaSource(uri, dataSourceFactory,
            new DefaultDashChunkSource.Factory(dataSourceFactory), null, null);

    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelector trackSelector = new DefaultTrackSelector(new AdaptiveTrackSelection.Factory(bandwidthMeter));

    SimpleExoPlayer simpleExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector);

    exoPlayerView.setPlayer(simpleExoPlayer);
    simpleExoPlayer.prepare(dashMediaSource);

Also add the dependencies to your build.gradle

compile 'com.google.android.exoplayer:exoplayer-core:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-dash:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-hls:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-smoothstreaming:r2.4.0'
compile 'com.google.android.exoplayer:exoplayer-ui:r2.4.0'
like image 158
alijandro Avatar answered Sep 17 '22 16:09

alijandro