From 1fb8bddf544476fa97d2db764391b6982855eab7 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 11:07:47 -0500 Subject: [PATCH 01/13] Upgrade android gradle and dependencies --- app/build.gradle | 18 +++++++++--------- build.gradle | 4 +++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) mode change 100644 => 100755 app/build.gradle mode change 100644 => 100755 build.gradle diff --git a/app/build.gradle b/app/build.gradle old mode 100644 new mode 100755 index cba54cd5..4d99286e --- a/app/build.gradle +++ b/app/build.gradle @@ -1,12 +1,12 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 25 - buildToolsVersion "25.0.2" + compileSdkVersion 27 + buildToolsVersion '27.0.3' defaultConfig { applicationId "com.example.android.classicalmusicquiz" minSdkVersion 15 - targetSdkVersion 25 + targetSdkVersion 27 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -20,12 +20,12 @@ android { } dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + implementation fileTree(dir: 'libs', include: ['*.jar']) + androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) - compile 'com.google.android.exoplayer:exoplayer:r2.2.0' - compile 'com.android.support:appcompat-v7:25.3.0' - testCompile 'junit:junit:4.12' - compile 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.google.android.exoplayer:exoplayer:2.8.0' + implementation 'com.android.support:appcompat-v7:27.1.1' + testImplementation 'junit:junit:4.12' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' } diff --git a/build.gradle b/build.gradle old mode 100644 new mode 100755 index 1ea4bd05..44bac8f9 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,10 @@ buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:2.3.0' + classpath 'com.android.tools.build:gradle:3.1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,6 +16,7 @@ buildscript { allprojects { repositories { jcenter() + google() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7aff1511..5afc033d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Mar 07 11:16:24 PST 2017 +#Fri May 18 11:01:52 CDT 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip From 3145985c1848f20e96606a327e068f6decf0fdec Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 11:44:23 -0500 Subject: [PATCH 02/13] Replace TODO references to deprecated SimpleExoPlayerView to PlayerView --- .../example/android/classicalmusicquiz/QuizActivity.java | 8 ++++---- app/src/main/res/layout/activity_quiz.xml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) mode change 100644 => 100755 app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java mode change 100644 => 100755 app/src/main/res/layout/activity_quiz.xml diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java old mode 100644 new mode 100755 index 0e47cf46..f5d49cef --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -47,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quiz); - // TODO (2): Replace the ImageView with the SimpleExoPlayerView, and remove the method calls on the composerView. + // TODO (2): Replace the ImageView with the PlayerView, and remove the method calls on the composerView. ImageView composerView = (ImageView) findViewById(R.id.composerView); boolean isNewGame = !getIntent().hasExtra(REMAINING_SONGS_KEY); @@ -69,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) { mQuestionSampleIDs = QuizUtils.generateQuestion(mRemainingSampleIDs); mAnswerSampleID = QuizUtils.getCorrectAnswerID(mQuestionSampleIDs); - // TODO (3): Replace the default artwork in the SimpleExoPlayerView with the question mark drawable. + // TODO (3): Replace the default artwork in the PlayerView with the question mark drawable. // Load the image of the composer for the answer into the ImageView. composerView.setImageBitmap(Sample.getComposerArtBySampleID(this, mAnswerSampleID)); @@ -91,7 +91,7 @@ protected void onCreate(Bundle savedInstanceState) { // In initializePayer // TODO (6): Instantiate a SimpleExoPlayer object using DefaultTrackSelector and DefaultLoadControl. // TODO (7): Prepare the MediaSource using DefaultDataSourceFactory and DefaultExtractorsFactory, as well as the Sample URI you passed in. - // TODO (8): Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the SimpleExoPlayerView. + // TODO (8): Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the PlayerView. /** @@ -178,7 +178,7 @@ private void showCorrectAnswer() { for (int i = 0; i < mQuestionSampleIDs.size(); i++) { int buttonSampleID = mQuestionSampleIDs.get(i); - // TODO (10): Change the default artwork in the SimpleExoPlayerView to show the picture of the composer, when the user has answered the question. + // TODO (10): Change the default artwork in the PlayerView to show the picture of the composer, when the user has answered the question. mButtons[i].setEnabled(false); if (buttonSampleID == mAnswerSampleID) { mButtons[i].getBackground().setColorFilter(ContextCompat.getColor diff --git a/app/src/main/res/layout/activity_quiz.xml b/app/src/main/res/layout/activity_quiz.xml old mode 100644 new mode 100755 index db8287d0..92a63297 --- a/app/src/main/res/layout/activity_quiz.xml +++ b/app/src/main/res/layout/activity_quiz.xml @@ -67,7 +67,7 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/buttonB" /> - + Date: Fri, 18 May 2018 12:10:15 -0500 Subject: [PATCH 03/13] Replace the Composer ImageView with a PlayerView that occupies the top half of your screen --- app/src/main/res/layout/activity_quiz.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/layout/activity_quiz.xml b/app/src/main/res/layout/activity_quiz.xml index 92a63297..733293bd 100755 --- a/app/src/main/res/layout/activity_quiz.xml +++ b/app/src/main/res/layout/activity_quiz.xml @@ -67,9 +67,9 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toBottomOf="@+id/buttonB" /> - - + + app:layout_constraintTop_toTopOf="parent"/> From d9dea05b18028150713bf0a383328281b82eb14c Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:29:32 -0500 Subject: [PATCH 04/13] Add //noinspection GradleCompatible to build.gradle --- app/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/app/build.gradle b/app/build.gradle index 4d99286e..819b27ad 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,6 +25,7 @@ dependencies { exclude group: 'com.android.support', module: 'support-annotations' }) implementation 'com.google.android.exoplayer:exoplayer:2.8.0' + //noinspection GradleCompatible implementation 'com.android.support:appcompat-v7:27.1.1' testImplementation 'junit:junit:4.12' implementation 'com.android.support.constraint:constraint-layout:1.1.0' From 11dad797837915af526d650641e7712323d7e5e9 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:31:02 -0500 Subject: [PATCH 05/13] Replace the ImageView with the PlayerView, and remove the method calls on the composerView --- .../example/android/classicalmusicquiz/QuizActivity.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index f5d49cef..6899cfd9 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -27,6 +27,8 @@ import android.widget.Button; import android.widget.ImageView; +import com.google.android.exoplayer2.ui.PlayerView; + import java.util.ArrayList; public class QuizActivity extends AppCompatActivity implements View.OnClickListener { @@ -47,8 +49,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quiz); - // TODO (2): Replace the ImageView with the PlayerView, and remove the method calls on the composerView. - ImageView composerView = (ImageView) findViewById(R.id.composerView); + // COMPLETED (2): Replace the ImageView with the PlayerView, and remove the method calls on the composerView. + PlayerView playerView = (PlayerView) findViewById(R.id.playerView); boolean isNewGame = !getIntent().hasExtra(REMAINING_SONGS_KEY); From 7cdd6434509a51f93fc8d47dd21b7a14df0499b7 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:34:01 -0500 Subject: [PATCH 06/13] Replace the default artwork in the PlayerView with the question mark drawable --- .../com/example/android/classicalmusicquiz/QuizActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 6899cfd9..d39bf77c 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -17,6 +17,7 @@ package com.example.android.classicalmusicquiz; import android.content.Intent; +import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; import android.os.Bundle; @@ -71,9 +72,9 @@ protected void onCreate(Bundle savedInstanceState) { mQuestionSampleIDs = QuizUtils.generateQuestion(mRemainingSampleIDs); mAnswerSampleID = QuizUtils.getCorrectAnswerID(mQuestionSampleIDs); - // TODO (3): Replace the default artwork in the PlayerView with the question mark drawable. + // COMPLETED (3): Replace the default artwork in the PlayerView with the question mark drawable. // Load the image of the composer for the answer into the ImageView. - composerView.setImageBitmap(Sample.getComposerArtBySampleID(this, mAnswerSampleID)); + playerView.setDefaultArtwork(BitmapFactory.decodeResource(getResources(), R.drawable.question_mark)); // If there is only one answer left, end the game. if (mQuestionSampleIDs.size() < 2) { From bc543e5bc9d5c7c3ac4d57661fa486242faa63ec Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:37:16 -0500 Subject: [PATCH 07/13] Create a Sample object using the Sample.getSampleByID() method and passing in mAnswerSampleID; --- .../example/android/classicalmusicquiz/QuizActivity.java | 9 ++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) mode change 100644 => 100755 app/src/main/res/values/strings.xml diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index d39bf77c..c0aec14a 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -27,6 +27,7 @@ import android.view.View; import android.widget.Button; import android.widget.ImageView; +import android.widget.Toast; import com.google.android.exoplayer2.ui.PlayerView; @@ -85,7 +86,13 @@ protected void onCreate(Bundle savedInstanceState) { // Initialize the buttons with the composers names. mButtons = initializeButtons(mQuestionSampleIDs); - // TODO (4): Create a Sample object using the Sample.getSampleByID() method and passing in mAnswerSampleID; + // COMPLETED (4): Create a Sample object using the Sample.getSampleByID() method and passing in mAnswerSampleID; + Sample answerSample = Sample.getSampleByID(this, mAnswerSampleID); + if(answerSample == null) { + Toast.makeText(this, getString(R.string.sample_not_found_error), + Toast.LENGTH_SHORT).show(); + return; + } // TODO (5): Create a method called initializePlayer() that takes a Uri as an argument and call it here, passing in the Sample URI. } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml old mode 100644 new mode 100755 index 0bcf88fb..8ef2c74a --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,4 +21,5 @@ Can you guess the composer? Press play to hear the piece! Error loading one or more samples! + Sample Not Found From 00daf0c21e80b309a15f935cb705b99676fd9d61 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:51:07 -0500 Subject: [PATCH 08/13] Change playerView to mPlayerView, create mExoPlayer, and create a method called initializePlayer() that takes a Uri as an argument and calls it, passing in the Sample URI. --- .../classicalmusicquiz/QuizActivity.java | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index c0aec14a..0b61c5e2 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -20,16 +20,27 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.PorterDuff; +import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; -import android.widget.ImageView; import android.widget.Toast; +import com.google.android.exoplayer2.DefaultLoadControl; +import com.google.android.exoplayer2.ExoPlayerFactory; +import com.google.android.exoplayer2.LoadControl; +import com.google.android.exoplayer2.SimpleExoPlayer; +import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory; +import com.google.android.exoplayer2.source.ExtractorMediaSource; +import com.google.android.exoplayer2.source.MediaSource; +import com.google.android.exoplayer2.trackselection.DefaultTrackSelector; +import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.ui.PlayerView; +import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory; +import com.google.android.exoplayer2.util.Util; import java.util.ArrayList; @@ -44,6 +55,8 @@ public class QuizActivity extends AppCompatActivity implements View.OnClickListe private int mCurrentScore; private int mHighScore; private Button[] mButtons; + private PlayerView mPlayerView; + private SimpleExoPlayer mExoPlayer; @Override @@ -52,7 +65,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.activity_quiz); // COMPLETED (2): Replace the ImageView with the PlayerView, and remove the method calls on the composerView. - PlayerView playerView = (PlayerView) findViewById(R.id.playerView); + mPlayerView = (PlayerView) findViewById(R.id.playerView); boolean isNewGame = !getIntent().hasExtra(REMAINING_SONGS_KEY); @@ -75,7 +88,7 @@ protected void onCreate(Bundle savedInstanceState) { // COMPLETED (3): Replace the default artwork in the PlayerView with the question mark drawable. // Load the image of the composer for the answer into the ImageView. - playerView.setDefaultArtwork(BitmapFactory.decodeResource(getResources(), R.drawable.question_mark)); + mPlayerView.setDefaultArtwork(BitmapFactory.decodeResource(getResources(), R.drawable.question_mark)); // If there is only one answer left, end the game. if (mQuestionSampleIDs.size() < 2) { @@ -93,8 +106,8 @@ protected void onCreate(Bundle savedInstanceState) { Toast.LENGTH_SHORT).show(); return; } - // TODO (5): Create a method called initializePlayer() that takes a Uri as an argument and call it here, passing in the Sample URI. - + // COMPLETED (5): Create a method called initializePlayer() that takes a Uri as an argument and call it here, passing in the Sample URI. + initializePlayer(Uri.parse(answerSample.getUri())); } @@ -125,6 +138,21 @@ private Button[] initializeButtons(ArrayList answerSampleIDs) { return buttons; } + private void initializePlayer(Uri mediaUri) { + if(mExoPlayer == null) { + TrackSelector trackSelector = new DefaultTrackSelector(); + LoadControl loadControl = new DefaultLoadControl(); + mExoPlayer = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl); + mPlayerView.setPlayer(mExoPlayer); + + String userAgent = Util.getUserAgent(this, "ClassicalMusicQuiz"); + MediaSource mediaSource = new ExtractorMediaSource(mediaUri, new DefaultDataSourceFactory( + this, userAgent), new DefaultExtractorsFactory(), null, null); + mExoPlayer.prepare(mediaSource); + mExoPlayer.setPlayWhenReady(true); + } + } + /** * The OnClick method for all of the answer buttons. The method uses the index of the button From c27e188347a7e97ffb9ea13f873e75ab8a542149 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:53:23 -0500 Subject: [PATCH 09/13] (Completed in last commit) Instantiate a SimpleExoPlayer object using DefaultTrackSelector and DefaultLoadControl --- .../com/example/android/classicalmusicquiz/QuizActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 0b61c5e2..830ccf6a 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -112,7 +112,7 @@ protected void onCreate(Bundle savedInstanceState) { // In initializePayer - // TODO (6): Instantiate a SimpleExoPlayer object using DefaultTrackSelector and DefaultLoadControl. + // COMPLETED (6): Instantiate a SimpleExoPlayer object using DefaultTrackSelector and DefaultLoadControl. // TODO (7): Prepare the MediaSource using DefaultDataSourceFactory and DefaultExtractorsFactory, as well as the Sample URI you passed in. // TODO (8): Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the PlayerView. From 375ca6a0b0e42217d0041ad26413d69ebbf8ba64 Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 12:58:07 -0500 Subject: [PATCH 10/13] Prepare the MediaSource using DefaultDataSourceFactory and DefaultExtractorsFactory, as well as the Sample URI you passed in. Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the PlayerView. --- .../com/example/android/classicalmusicquiz/QuizActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 830ccf6a..65f2dd53 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -113,8 +113,8 @@ protected void onCreate(Bundle savedInstanceState) { // In initializePayer // COMPLETED (6): Instantiate a SimpleExoPlayer object using DefaultTrackSelector and DefaultLoadControl. - // TODO (7): Prepare the MediaSource using DefaultDataSourceFactory and DefaultExtractorsFactory, as well as the Sample URI you passed in. - // TODO (8): Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the PlayerView. + // COMPLETED (7): Prepare the MediaSource using DefaultDataSourceFactory and DefaultExtractorsFactory, as well as the Sample URI you passed in. + // COMPLETED (8): Prepare the ExoPlayer with the MediaSource, start playing the sample and set the SimpleExoPlayer to the PlayerView. /** From 8cbedc693dac96fb73a745b37b9779d363c3e68b Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 13:02:37 -0500 Subject: [PATCH 11/13] Override onDestroy() to stop and release the player when the Activity is destroyed --- .../android/classicalmusicquiz/QuizActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 65f2dd53..99ee6384 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -153,6 +153,11 @@ private void initializePlayer(Uri mediaUri) { } } + private void releasePlayer() { + mExoPlayer.stop(); + mExoPlayer.release(); + mExoPlayer = null; + } /** * The OnClick method for all of the answer buttons. The method uses the index of the button @@ -233,5 +238,11 @@ private void showCorrectAnswer() { } } - // TODO (11): Override onDestroy() to stop and release the player when the Activity is destroyed. + // COMPLETED (11): Override onDestroy() to stop and release the player when the Activity is destroyed. + + @Override + protected void onDestroy() { + super.onDestroy(); + releasePlayer(); + } } From 63a30fc6cd0613672b322df9009fb756e991246f Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 13:04:04 -0500 Subject: [PATCH 12/13] Change the default artwork in the PlayerView to show the picture of the composer, when the user has answered the question. --- .../com/example/android/classicalmusicquiz/QuizActivity.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 99ee6384..584e037f 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -221,8 +221,10 @@ private void showCorrectAnswer() { for (int i = 0; i < mQuestionSampleIDs.size(); i++) { int buttonSampleID = mQuestionSampleIDs.get(i); - // TODO (10): Change the default artwork in the PlayerView to show the picture of the composer, when the user has answered the question. + // COMPLETED (10): Change the default artwork in the PlayerView to show the picture of the composer, when the user has answered the question. mButtons[i].setEnabled(false); + mPlayerView.setDefaultArtwork(Sample.getComposerArtBySampleID(this, mAnswerSampleID)); + if (buttonSampleID == mAnswerSampleID) { mButtons[i].getBackground().setColorFilter(ContextCompat.getColor (this, android.R.color.holo_green_light), From d96294da8e8f275120a80f9aa86e758f8b7bdeee Mon Sep 17 00:00:00 2001 From: Jantz Date: Fri, 18 May 2018 13:06:29 -0500 Subject: [PATCH 13/13] Stop the playback when you go to the next question --- .../com/example/android/classicalmusicquiz/QuizActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java index 584e037f..8ba1e00e 100755 --- a/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java +++ b/app/src/main/java/com/example/android/classicalmusicquiz/QuizActivity.java @@ -204,7 +204,8 @@ public void onClick(View v) { handler.postDelayed(new Runnable() { @Override public void run() { - // TODO (9): Stop the playback when you go to the next question. + // COMPLETED (9): Stop the playback when you go to the next question. + mExoPlayer.stop(); Intent nextQuestionIntent = new Intent(QuizActivity.this, QuizActivity.class); nextQuestionIntent.putExtra(REMAINING_SONGS_KEY, mRemainingSampleIDs); finish();