// Path: checkpoint_6/src/main/java/com/android/example/leanback/data/Video.java
// public class Video implements Serializable {
// 
//     public static final String INTENT_EXTRA_VIDEO = "INTENT_EXTRA_VIDEO";
//     private long id;
//     private int year;
//     private int rating;
//     private String description;
//     private String title;
//     private String thumbUrl;
//     private String contentUrl;
//     private String category;
//     private String tags;
// 
//     public int getYear() {
//         return year;
//     }
// 
//     public void setYear(int year) {
//         this.year = year;
//     }
// 
//     public int getRating() {
//         return rating;
//     }
// 
//     public void setRating(int rating) {
//         this.rating = rating;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getThumbUrl() {
//         return thumbUrl;
//     }
// 
//     public void setThumbUrl(String thumbUrl) {
//         this.thumbUrl = thumbUrl;
//     }
// 
//     public String getContentUrl() {
//         return contentUrl;
//     }
// 
//     public void setContentUrl(String contentUrl) {
//         this.contentUrl = contentUrl;
//     }
// 
//     public String getCategory() {
//         return category;
//     }
// 
//     public void setCategory(String category) {
//         this.category = category;
//     }
// 
//     public String getTags() {
//         return tags;
//     }
// 
//     public void setTags(String tags) {
//         this.tags = tags;
//     }
// 
//     public void setId(long id) {
//         this.id = id;
//     }
// 
//     public long getId() {
//         return id;
//     }
// }


import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodec.CryptoException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;
import android.widget.MediaController;
import android.widget.Toast;
import com.android.example.leanback.data.Video;
import com.google.android.exoplayer.ExoPlaybackException;
import com.google.android.exoplayer.ExoPlayer;
import com.google.android.exoplayer.FrameworkSampleSource;
import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
import com.google.android.exoplayer.MediaCodecTrackRenderer.DecoderInitializationException;
import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
import com.google.android.exoplayer.SampleSource;
import com.google.android.exoplayer.TrackRenderer;
import com.google.android.exoplayer.VideoSurfaceView;
import com.google.android.exoplayer.util.PlayerControl;
/*
 * Copyright 2014 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.example.leanback;



/**
 * An activity that plays media using {@link com.google.android.exoplayer.ExoPlayer}.
 */
public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
        ExoPlayer.Listener, MediaCodecVideoTrackRenderer.EventListener {

    public static final int RENDERER_COUNT = 2;

    private static final String TAG = "PlayerActivity";

    private Video mVideo;

    private MediaController mediaController;
    private View shutterView;
    private VideoSurfaceView surfaceView;

    private ExoPlayer player;
    private MediaCodecVideoTrackRenderer videoRenderer;

    private boolean autoPlay = true;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);

// Path: checkpoint_6/src/main/java/com/android/example/leanback/data/Video.java
// public class Video implements Serializable {
// 
//     public static final String INTENT_EXTRA_VIDEO = "INTENT_EXTRA_VIDEO";
//     private long id;
//     private int year;
//     private int rating;
//     private String description;
//     private String title;
//     private String thumbUrl;
//     private String contentUrl;
//     private String category;
//     private String tags;
// 
//     public int getYear() {
//         return year;
//     }
// 
//     public void setYear(int year) {
//         this.year = year;
//     }
// 
//     public int getRating() {
//         return rating;
//     }
// 
//     public void setRating(int rating) {
//         this.rating = rating;
//     }
// 
//     public String getDescription() {
//         return description;
//     }
// 
//     public void setDescription(String description) {
//         this.description = description;
//     }
// 
//     public String getTitle() {
//         return title;
//     }
// 
//     public void setTitle(String title) {
//         this.title = title;
//     }
// 
//     public String getThumbUrl() {
//         return thumbUrl;
//     }
// 
//     public void setThumbUrl(String thumbUrl) {
//         this.thumbUrl = thumbUrl;
//     }
// 
//     public String getContentUrl() {
//         return contentUrl;
//     }
// 
//     public void setContentUrl(String contentUrl) {
//         this.contentUrl = contentUrl;
//     }
// 
//     public String getCategory() {
//         return category;
//     }
// 
//     public void setCategory(String category) {
//         this.category = category;
//     }
// 
//     public String getTags() {
//         return tags;
//     }
// 
//     public void setTags(String tags) {
//         this.tags = tags;
//     }
// 
//     public void setId(long id) {
//         this.id = id;
//     }
// 
//     public long getId() {
//         return id;
//     }
// }


// Path: checkpoint_5/src/main/java/com/android/example/leanback/PlayerActivity.java
import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodec.CryptoException;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.View;
import android.widget.MediaController;
import android.widget.Toast;
import com.android.example.leanback.data.Video;
import com.google.android.exoplayer.ExoPlaybackException;
import com.google.android.exoplayer.ExoPlayer;
import com.google.android.exoplayer.FrameworkSampleSource;
import com.google.android.exoplayer.MediaCodecAudioTrackRenderer;
import com.google.android.exoplayer.MediaCodecTrackRenderer.DecoderInitializationException;
import com.google.android.exoplayer.MediaCodecVideoTrackRenderer;
import com.google.android.exoplayer.SampleSource;
import com.google.android.exoplayer.TrackRenderer;
import com.google.android.exoplayer.VideoSurfaceView;
import com.google.android.exoplayer.util.PlayerControl;

/*
 * Copyright 2014 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.example.leanback;



/**
 * An activity that plays media using {@link com.google.android.exoplayer.ExoPlayer}.
 */
public class PlayerActivity extends Activity implements SurfaceHolder.Callback,
        ExoPlayer.Listener, MediaCodecVideoTrackRenderer.EventListener {

    public static final int RENDERER_COUNT = 2;

    private static final String TAG = "PlayerActivity";

    private Video mVideo;

    private MediaController mediaController;
    private View shutterView;
    private VideoSurfaceView surfaceView;

    private ExoPlayer player;
    private MediaCodecVideoTrackRenderer videoRenderer;

    private boolean autoPlay = true;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_player);

        mVideo = (Video) getIntent().getSerializableExtra(Video.INTENT_EXTRA_VIDEO);