// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java
// public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder {
// 
//     public DashRenderBuilder(Context context, String userAgent, String url) {
//         this(context, userAgent, url, AudioManager.STREAM_MUSIC);
//     }
// 
//     public DashRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }
// 
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java
// @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder {
// 
//     public HlsRenderBuilder(Context context, String userAgent, String url) {
//         super(context, userAgent, url);
//     }
// 
//     public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }
// 
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java
// @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder {
// 
//     public SmoothStreamRenderBuilder(Context context, String userAgent, String url) {
//         this(context, userAgent, url, AudioManager.STREAM_MUSIC);
//     }
// 
//     public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }


import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import com.devbrackets.android.exomedia.core.builder.RenderBuilder;
import com.devbrackets.android.exomedia.core.video.ExoVideoView;
import com.devbrackets.android.exomedia.type.MediaSourceType;
import com.devbrackets.android.exomedia.ui.widget.EMVideoView;
import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder;
import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder;
import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder;

    public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public void setVideoURI(Uri uri) {
        RenderBuilder builder = null;

        if(uri != null) {
            builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri);
        }

        setVideoURI(uri, builder);
    }

    protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) {
        String userAgent = "";
        if (videoViewImpl instanceof ExoVideoView) {
            userAgent = ((ExoVideoView) videoViewImpl).getUserAgent();
        }
        switch (renderType) {
            case HLS:
                return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
            case DASH:
                return new DashRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
            case SMOOTH_STREAM:
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/DashRenderBuilder.java
// public class DashRenderBuilder extends com.devbrackets.android.exomedia.core.builder.DashRenderBuilder {
// 
//     public DashRenderBuilder(Context context, String userAgent, String url) {
//         this(context, userAgent, url, AudioManager.STREAM_MUSIC);
//     }
// 
//     public DashRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }
// 
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/HlsRenderBuilder.java
// @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// public class HlsRenderBuilder extends com.devbrackets.android.exomedia.core.builder.HlsRenderBuilder {
// 
//     public HlsRenderBuilder(Context context, String userAgent, String url) {
//         super(context, userAgent, url);
//     }
// 
//     public HlsRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }
// 
// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/builder/SmoothStreamRenderBuilder.java
// @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
// public class SmoothStreamRenderBuilder extends com.devbrackets.android.exomedia.core.builder.SmoothStreamRenderBuilder {
// 
//     public SmoothStreamRenderBuilder(Context context, String userAgent, String url) {
//         this(context, userAgent, url, AudioManager.STREAM_MUSIC);
//     }
// 
//     public SmoothStreamRenderBuilder(Context context, String userAgent, String url, int streamType) {
//         super(context, userAgent, url, streamType);
//     }
// 
//     @SuppressWarnings("UnusedParameters") // Context kept for consistency with the HLS and Dash builders
//     protected UriDataSource createManifestDataSource(Context context, String userAgent) {
//         return new OkUriDataSource(context, userAgent);
//     }
// 
// }


// Path: app/src/main/java/eu/se_bastiaan/tvnl/exomedia/TVNLVideoView.java
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import com.devbrackets.android.exomedia.core.builder.RenderBuilder;
import com.devbrackets.android.exomedia.core.video.ExoVideoView;
import com.devbrackets.android.exomedia.type.MediaSourceType;
import com.devbrackets.android.exomedia.ui.widget.EMVideoView;
import eu.se_bastiaan.tvnl.exomedia.builder.DashRenderBuilder;
import eu.se_bastiaan.tvnl.exomedia.builder.HlsRenderBuilder;
import eu.se_bastiaan.tvnl.exomedia.builder.SmoothStreamRenderBuilder;


    public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public TVNLVideoView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public void setVideoURI(Uri uri) {
        RenderBuilder builder = null;

        if(uri != null) {
            builder = getRendererBuilder(MediaSourceType.getByLooseComparison(uri), uri);
        }

        setVideoURI(uri, builder);
    }

    protected RenderBuilder getRendererBuilder(@NonNull MediaSourceType renderType, @NonNull Uri uri) {
        String userAgent = "";
        if (videoViewImpl instanceof ExoVideoView) {
            userAgent = ((ExoVideoView) videoViewImpl).getUserAgent();
        }
        switch (renderType) {
            case HLS:
                return new HlsRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
            case DASH:
                return new DashRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());
            case SMOOTH_STREAM:
                return new SmoothStreamRenderBuilder(getContext().getApplicationContext(), userAgent, uri.toString());