Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package one.vigo.top.services.uxzoom;
- import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap;
- import one.vigo.top.services.uxzoom.data.model.cassandra.BufferingType;
- import one.vigo.top.services.uxzoom.rest.model.PlaybackEvent;
- public class PlayingSM {
- public static enum State{
- NULL((byte) 0),
- PLAYING((byte) 1),
- PAUSED((byte) 2),
- STOPPED((byte) 3);
- private static final Byte2ObjectOpenHashMap<PlayingSM.State> values;
- static {
- Byte2ObjectOpenHashMap<PlayingSM.State> vs = new Byte2ObjectOpenHashMap<>();
- for(PlayingSM.State bf : values()) {
- vs.put(bf.value, bf);
- }
- values = vs;
- }
- private final byte value;
- private State(byte value) {
- this.value = value;
- }
- public byte getValue() {
- return value;
- }
- public static PlayingSM.State fromValue(byte value) {
- return values.get(value);
- }
- }
- private BufferingSM bufferingSM;
- private State state;
- public void sendEvent(PlaybackEvent.Type evType)
- {
- switch(evType){
- case PLAY:
- processingPlayEvent();
- break;
- case STOP:
- processingStopEvent();
- break;
- case PAUSE:
- //processingPauseEvent();
- break;
- }
- }
- private void processingPlayEvent()
- {
- if (state == State.NULL)
- {
- bufferingSM = new BufferingSM();
- bufferingSM.start(state, BufferingType.INIT);
- }
- }
- private void processingStopEvent() {
- switch (state) {
- case PLAYING:
- bufferingSM.end(state);
- break;
- }
- }
- public BufferingSM getBufferingSM() {
- return bufferingSM;
- }
- public void setBufferingSM(BufferingSM bufferingSM) {
- this.bufferingSM = bufferingSM;
- }
- public State getType() {
- return state;
- }
- public void setType(State state) {
- this.state = state;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement