Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find Simple ExoPlayer Example #2210

lioun1729 opened this issue Dec 16, 2016 · 6 comments


Copy link

commented Dec 16, 2016

My object implements Simple ExoPlayer for DASH Stream

So, I try to find simple exoplayer example (using basic exoplayer library and method)

but I can't find that..

Please help, The demo app code is too hard to me

@ojw28 ojw28 added the question label Dec 16, 2016


This comment has been minimized.

Copy link

commented Dec 17, 2016

I implemented simple dash stream player using SimpleExoPlayer API

Add My code this comment, soon


This comment has been minimized.

Copy link

commented Dec 18, 2016

Here is my code

This code is very simple example for playing one Dash Stream (by Big Bunny MPD)

// Variables
private static final String VIDEO_URI =

private SimpleExoPlayer player;
private SimpleExoPlayerView simpleExoPlayerView;
private Handler mainHandler;
private TrackSelection.Factory videoTrackSelectionFactory;
private TrackSelector trackSelector;
private LoadControl loadControl;
private DataSource.Factory dataSourceFactory;
private MediaSource videoSource;
private Uri uri;
private String userAgent;
private static final DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

// Activity onCreate
protected void onCreate(Bundle savedInstanceState) {
    simpleExoPlayerView = (SimpleExoPlayerView)findViewById(;
    userAgent = Util.getUserAgent(this,"SimpleDashExoPlayer");

// Create TrackSelection Factory, Track Selector, Handler, Load Control, and ExoPlayer Instance
public void createPlayer(){
    mainHandler = new Handler();
    videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter);
    trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
    loadControl = new DefaultLoadControl();
    player = ExoPlayerFactory.newSimpleInstance(this,trackSelector,loadControl);

// Set player to SimpleExoPlayerView
public void attachPlayerView(){

// Build Data Source Factory, Dash Media Source, and Prepare player using videoSource
public void preparePlayer(){
    dataSourceFactory = buildDataSourceFactory(bandwidthMeter);
    videoSource = new DashMediaSource(uri,buildDataSourceFactory(null),new DefaultDashChunkSource.Factory(dataSourceFactory),mainHandler,null);

// Parse VIDEO_URI and Save at uri variable
public void uriParse(){
    uri = Uri.parse(VIDEO_URI);

// Build Data Source Factory using DefaultBandwidthMeter and HttpDataSource.Factory
private DataSource.Factory buildDataSourceFactory(DefaultBandwidthMeter bandwidthMeter){
    return new DefaultDataSourceFactory(this, bandwidthMeter, buildHttpDataSourceFactory(bandwidthMeter));

// Build Http Data Source Factory using DefaultBandwidthMeter
private HttpDataSource.Factory buildHttpDataSourceFactory(DefaultBandwidthMeter bandwidthMeter){
    return new DefaultHttpDataSourceFactory(userAgent, bandwidthMeter);

// Activity onStop, player must be release because of memory saving
public void onStop(){

In activity xml file just use below,

< android:id="@+id/player_view"


I'm first at ExoPlayer Development, so this code may be strange

Even so, example code run without problems

@ojw28 ojw28 closed this Dec 18, 2016


This comment has been minimized.

Copy link

commented Feb 28, 2017

mmmm are you sure this code work fine !!!!
are you test mp4 or other format
in my issue #2505 i use similar code but when i want to play mp4 format i just see a black page
can you help me !?


This comment has been minimized.

Copy link

commented Mar 24, 2017

This example is only for one dash stream
So, you must modify this code if you want to use the other format


This comment has been minimized.

Copy link

commented Apr 21, 2017

How can we play mp4 videos with exoplayer? Can you please help


This comment has been minimized.

Copy link

commented Apr 22, 2017

I have no more experience about developing exoplayer app now

But I think that change class or object using by videoSource variable to play only mp4 data

Or you can see how to play and configure various video format data on exoplayer in demo app uploaded ExoPlayer github site

@google google locked and limited conversation to collaborators Jun 28, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
4 participants
You can’t perform that action at this time.