mirror of
https://github.com/KDE/kasts.git
synced 2025-01-27 15:49:24 +01:00
Refactor the switch statement.
This commit is contained in:
parent
09005b232d
commit
f43eecb74a
@ -41,6 +41,7 @@ public class KastsActivity extends QtActivity
|
|||||||
public long position;
|
public long position;
|
||||||
public long duration;
|
public long duration;
|
||||||
public float playbackSpeed;
|
public float playbackSpeed;
|
||||||
|
public int state = 2;
|
||||||
// add more variables here
|
// add more variables here
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +58,16 @@ public class KastsActivity extends QtActivity
|
|||||||
|
|
||||||
MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder();
|
MediaMetadataCompat.Builder metadata = new MediaMetadataCompat.Builder();
|
||||||
|
|
||||||
|
switch(mediaData.state)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
mPBuilder.setState(PlaybackStateCompat.STATE_PLAYING, mediaData.position, mediaData.playbackSpeed);
|
||||||
|
case 1:
|
||||||
|
mPBuilder.setState(PlaybackStateCompat.STATE_PAUSED, mediaData.position, mediaData.playbackSpeed);
|
||||||
|
case 2:
|
||||||
|
mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed);
|
||||||
|
}
|
||||||
|
|
||||||
metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, "The title");
|
metadata.putString(MediaMetadataCompat.METADATA_KEY_TITLE, "The title");
|
||||||
metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, "Author");
|
metadata.putString(MediaMetadataCompat.METADATA_KEY_AUTHOR, "Author");
|
||||||
metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, "Author");
|
metadata.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, "Author");
|
||||||
@ -194,15 +205,9 @@ public class KastsActivity extends QtActivity
|
|||||||
public static void setSessionState(int state)
|
public static void setSessionState(int state)
|
||||||
{
|
{
|
||||||
//TODO: set state in mediadata
|
//TODO: set state in mediadata
|
||||||
switch(state)
|
|
||||||
{
|
mediaData.state = state;
|
||||||
case 0:
|
|
||||||
mPBuilder.setState(PlaybackStateCompat.STATE_PLAYING, mediaData.position, mediaData.playbackSpeed);
|
|
||||||
case 1:
|
|
||||||
mPBuilder.setState(PlaybackStateCompat.STATE_PAUSED, mediaData.position, mediaData.playbackSpeed);
|
|
||||||
case 2:
|
|
||||||
mPBuilder.setState(PlaybackStateCompat.STATE_STOPPED, mediaData.position, mediaData.playbackSpeed);
|
|
||||||
}
|
|
||||||
activity.updateNotification();
|
activity.updateNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user