NoSloppy

music_player

Jun 23rd, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. /*
  2.  
  3. music_player.h
  4.  
  5. supports per font (or common) music player function
  6.  
  7. note: for each font where you want their own music to play, please make sure
  8. your preset has a font search path, and that you add the track folder like so:
  9.  
  10. ;font/music
  11.  
  12. then create your music folder under that font, and populate it with 00xx.wav files
  13.  
  14. note: if you want to share common music between fonts, try something like this:
  15.  
  16. ;common/music
  17.  
  18. */
  19.  
  20. // music_player uses its own button to start playing musicXX.wav files
  21. // found anywhere in the font search path (see install info above)
  22. // TRIGGER + POINT UP to play NEXT music, TRIGGER + POINT DOWN to play PREV music
  23. // the original music trigger button STOPS the new music_player
  24. // and will also start/stop the original track player
  25.  
  26. // TODO: add another mode that
  27. // checks when music is finished, then starts the other music
  28. // until all are played through, then stop
  29.  
  30.  
  31.  
  32. // next and previous music
  33. case EVENTID(BUTTON_POWER, EVENT_HELD_LONG, MODE_OFF):
  34. // Edit to whatever button action you want to activate the music, saber off or on or both.
  35. if (!mode_volume_)
  36. {
  37. if (pointing_down_)
  38. {
  39. // PREV music
  40. playNumber--;
  41. if (playNumber <1)
  42. {
  43. playNumber=10;
  44. ::CommandParser::DoParse("play", "next.wav");
  45. }
  46. else
  47. ::CommandParser::DoParse("play", "prev.wav");
  48.  
  49. }
  50. else
  51. {
  52. // NEXT music
  53. playNumber++;
  54. if (playNumber >10)
  55. {
  56. playNumber=1;
  57. ::CommandParser::DoParse("play", "prev.wav");
  58. }
  59. else
  60. ::CommandParser::DoParse("play", "next.wav");
  61. }
  62.  
  63. // music selection
  64. if (playNumber > 9)
  65. {
  66. playFile = "music10.wav";
  67. }
  68. else if (playNumber > 8)
  69. {
  70. playFile = "music09.wav";
  71. }
  72. else if (playNumber > 7)
  73. {
  74. playFile = "music08.wav";
  75. }
  76. else if (playNumber > 6)
  77. {
  78. playFile = "music07.wav";
  79. }
  80. else if (playNumber > 5)
  81. {
  82. playFile = "music06.wav";
  83. }
  84. else if (playNumber > 4)
  85. {
  86. playFile = "music05.wav";
  87. }
  88. else if (playNumber > 3)
  89. {
  90. playFile = "music04.wav";
  91. }
  92. else if (playNumber > 2)
  93. {
  94. playFile = "music03.wav";
  95. }
  96. else if (playNumber > 1)
  97. {
  98. playFile = "music02.wav";
  99. }
  100. else
  101. {
  102. playFile = "music01.wav";
  103. }
  104.  
  105. // play sequential music
  106. ::CommandParser::DoParse("play_track", playFile);
  107. }
  108. return true;
  109.  
Advertisement
Add Comment
Please, Sign In to add comment