mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-19 15:17:50 +01:00
Use names for playstates
These names need to be mapped to device specific constants in the device code.
This commit is contained in:
parent
91f374edec
commit
c5262869d9
@ -359,14 +359,16 @@ public class NotificationListener extends NotificationListenerService {
|
||||
stateSpec.shuffle = 1;
|
||||
switch (s.getState()) {
|
||||
case PlaybackState.STATE_PLAYING:
|
||||
stateSpec.state = 0x01;
|
||||
stateSpec.state = MusicStateSpec.STATE_PLAYING;
|
||||
break;
|
||||
case PlaybackState.STATE_STOPPED:
|
||||
stateSpec.state = MusicStateSpec.STATE_STOPPED;
|
||||
break;
|
||||
case PlaybackState.STATE_PAUSED:
|
||||
stateSpec.state = 0x00;
|
||||
stateSpec.state = MusicStateSpec.STATE_PAUSED;
|
||||
break;
|
||||
default:
|
||||
stateSpec.state = 0x04;
|
||||
stateSpec.state = MusicStateSpec.STATE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,11 @@ package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
* Created by steffen on 07.06.16.
|
||||
*/
|
||||
public class MusicStateSpec {
|
||||
public static final int STATE_PLAYING = 0;
|
||||
public static final int STATE_PAUSED = 1;
|
||||
public static final int STATE_STOPPED = 2;
|
||||
public static final int STATE_UNKNOWN = 3;
|
||||
|
||||
public byte state;
|
||||
public int position;
|
||||
public int playRate;
|
||||
|
@ -35,6 +35,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||
@ -1102,6 +1103,20 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
}
|
||||
|
||||
public byte[] encodeSetMusicState(byte state, int position, int playRate, byte shuffle, byte repeat) {
|
||||
byte playState;
|
||||
|
||||
switch (state) {
|
||||
case MusicStateSpec.STATE_PLAYING:
|
||||
playState = MUSICCONTROL_STATE_PLAYING;
|
||||
break;
|
||||
case MusicStateSpec.STATE_PAUSED:
|
||||
playState = MUSICCONTROL_STATE_PAUSED;
|
||||
break;
|
||||
default:
|
||||
playState = MUSICCONTROL_STATE_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
int length = LENGTH_PREFIX + 12;
|
||||
// Encode Prefix
|
||||
ByteBuffer buf = ByteBuffer.allocate(length);
|
||||
@ -1111,7 +1126,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||
|
||||
buf.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buf.put(MUSICCONTROL_SETPLAYSTATE);
|
||||
buf.put(state);
|
||||
buf.put(playState);
|
||||
buf.putInt(position);
|
||||
buf.putInt(playRate);
|
||||
buf.put(shuffle);
|
||||
|
Loading…
Reference in New Issue
Block a user