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

Stop button in AudioPlayerActivity #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public class AudioPlayerActivity extends AppCompatActivity implements PlaylistLi

private ImageButton previousButton;
private ImageButton playPauseButton;
private ImageButton stopButton;
private ImageButton nextButton;

private MediaRouteButton castButton;
Expand Down Expand Up @@ -235,6 +236,7 @@ private void updatePlayPauseImage(boolean isPlaying) {
*/
public void loadCompleted() {
playPauseButton.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.VISIBLE);
previousButton.setVisibility(View.VISIBLE);
nextButton.setVisibility(View.VISIBLE );

Expand All @@ -247,6 +249,7 @@ public void loadCompleted() {
*/
public void restartLoading() {
playPauseButton.setVisibility(View.INVISIBLE);
stopButton.setVisibility(View.INVISIBLE);
previousButton.setVisibility(View.INVISIBLE);
nextButton.setVisibility(View.INVISIBLE );

Expand Down Expand Up @@ -308,6 +311,7 @@ private void retrieveViews() {

previousButton = findViewById(R.id.audio_player_previous);
playPauseButton = findViewById(R.id.audio_player_play_pause);
stopButton = findViewById(R.id.audio_player_stop);
nextButton = findViewById(R.id.audio_player_next);

castButton = findViewById(R.id.media_route_button);
Expand Down Expand Up @@ -335,6 +339,13 @@ public void onClick(View v) {
}
});

stopButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
playlistManager.invokeStop();
}
});

nextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
9 changes: 9 additions & 0 deletions demo/src/main/res/drawable/ic_stop_black_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="36dp"
android:height="36dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6,6h12v12H6z"/>
</vector>
13 changes: 13 additions & 0 deletions demo/src/main/res/layout/audio_player_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@
android:layout_width="44dp"
android:layout_height="match_parent"/>

<ImageButton
android:id="@+id/audio_player_stop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:scaleType="centerInside"
app:srcCompat="@drawable/ic_stop_black_24dp"
tools:ignore="ContentDescription"/>

<android.support.v4.widget.Space
android:layout_width="44dp"
android:layout_height="match_parent"/>

<ImageButton
android:id="@+id/audio_player_next"
android:layout_width="wrap_content"
Expand Down