Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. package one.vigo.top.services.uxzoom;
  2.  
  3. import it.unimi.dsi.fastutil.bytes.Byte2ObjectOpenHashMap;
  4. import one.vigo.top.services.uxzoom.data.model.cassandra.BufferingType;
  5. import one.vigo.top.services.uxzoom.rest.model.PlaybackEvent;
  6.  
  7. public class PlayingSM {
  8.  
  9. public static enum State{
  10. NULL((byte) 0),
  11. PLAYING((byte) 1),
  12. PAUSED((byte) 2),
  13. STOPPED((byte) 3);
  14.  
  15. private static final Byte2ObjectOpenHashMap<PlayingSM.State> values;
  16. static {
  17. Byte2ObjectOpenHashMap<PlayingSM.State> vs = new Byte2ObjectOpenHashMap<>();
  18. for(PlayingSM.State bf : values()) {
  19. vs.put(bf.value, bf);
  20. }
  21. values = vs;
  22. }
  23.  
  24. private final byte value;
  25.  
  26. private State(byte value) {
  27. this.value = value;
  28. }
  29.  
  30. public byte getValue() {
  31. return value;
  32. }
  33.  
  34. public static PlayingSM.State fromValue(byte value) {
  35. return values.get(value);
  36. }
  37. }
  38.  
  39.  
  40. private BufferingSM bufferingSM;
  41. private State state;
  42.  
  43.  
  44. public void sendEvent(PlaybackEvent.Type evType)
  45. {
  46. switch(evType){
  47. case PLAY:
  48. processingPlayEvent();
  49. break;
  50. case STOP:
  51. processingStopEvent();
  52. break;
  53. case PAUSE:
  54. //processingPauseEvent();
  55. break;
  56. }
  57. }
  58.  
  59. private void processingPlayEvent()
  60. {
  61. if (state == State.NULL)
  62. {
  63. bufferingSM = new BufferingSM();
  64. bufferingSM.start(state, BufferingType.INIT);
  65. }
  66. }
  67.  
  68. private void processingStopEvent() {
  69. switch (state) {
  70. case PLAYING:
  71. bufferingSM.end(state);
  72. break;
  73. }
  74. }
  75.  
  76.  
  77.  
  78. public BufferingSM getBufferingSM() {
  79. return bufferingSM;
  80. }
  81.  
  82. public void setBufferingSM(BufferingSM bufferingSM) {
  83. this.bufferingSM = bufferingSM;
  84. }
  85.  
  86. public State getType() {
  87. return state;
  88. }
  89.  
  90. public void setType(State state) {
  91. this.state = state;
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement