Show current album in textview
This commit is contained in:
parent
a657211788
commit
ec42f11bc6
|
@ -81,12 +81,14 @@ public class MainActivity extends AppCompatActivity {
|
|||
public void onResponse(JSONObject response) {
|
||||
if (response.length() > 0) {
|
||||
try {
|
||||
String current = response.getString("artist") + " - " + response.getString("title");
|
||||
TextView statusTextView = findViewById(R.id.currentlyPlayingText);
|
||||
TextView statusTextView = findViewById(R.id.statusText);
|
||||
TextView albumTextView = findViewById(R.id.albumText);
|
||||
ImageButton playButton = findViewById(R.id.playButton);
|
||||
ImageButton shuffleButton = findViewById(R.id.shuffleButton);
|
||||
|
||||
String current = response.getString("artist") + " - " + response.getString("title");
|
||||
statusTextView.setText(current);
|
||||
albumTextView.setText(response.getString("album"));
|
||||
if (response.getBoolean("playing")) {
|
||||
playButton.setImageResource(R.drawable.ic_pause_black_24dp);
|
||||
} else {
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
app:layout_constraintTop_toBottomOf="@+id/volUpButton" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currentlyPlayingText"
|
||||
android:id="@+id/statusText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
|
@ -131,4 +131,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/playButton" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/albumText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:textAlignment="center"
|
||||
android:textSize="18sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/statusText" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
|
@ -60,14 +60,16 @@ def query():
|
|||
status['playing'] = True
|
||||
elif line == 'status paused':
|
||||
status['playing'] = False
|
||||
elif line.startswith('tag artist '):
|
||||
status['artist'] = line[11:]
|
||||
elif line.startswith('tag title '):
|
||||
status['title'] = line[10:]
|
||||
elif line == 'set shuffle true':
|
||||
status['shuffle'] = True
|
||||
elif line == 'set shuffle false':
|
||||
status['shuffle'] = False
|
||||
elif line.startswith('tag artist '):
|
||||
status['artist'] = line[11:]
|
||||
elif line.startswith('tag album '):
|
||||
status['album'] = line[10:]
|
||||
elif line.startswith('tag title '):
|
||||
status['title'] = line[10:]
|
||||
|
||||
return jsonify(status)
|
||||
|
||||
|
|
Loading…
Reference in New Issue