Guest User

Playback Counter

a guest
Sep 22nd, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | Source Code | 0 0
  1. desc:Playback Counter
  2.  
  3. @init
  4. playback_count = 0;
  5. last_play_state = 0;
  6.  
  7. @block
  8. // Check play state changes
  9. current_play_state = play_state;
  10.  
  11. // Detect when playback starts
  12. current_play_state == 1 && last_play_state != 1 ? (
  13. playback_count += 1;
  14. );
  15. last_play_state = current_play_state;
  16.  
  17. @gfx 200 100
  18.  
  19. // Set minimum size
  20. gfx_w = max(gfx_w, 200);
  21. gfx_h = max(gfx_h, 100);
  22.  
  23. // Deep slate background (dark blue-gray)
  24. gfx_r = 0.15;
  25. gfx_g = 0.20;
  26. gfx_b = 0.25;
  27. gfx_a = 1;
  28. gfx_rect(0, 0, gfx_w, gfx_h);
  29.  
  30. // Set white text color
  31. gfx_r = 1;
  32. gfx_g = 1;
  33. gfx_b = 1;
  34. gfx_a = 1;
  35.  
  36. // Calculate font size based on window size
  37. font_size = min(gfx_w * 0.15, gfx_h * 0.4);
  38. font_size = max(font_size, 12);
  39. gfx_setfont(1, "Arial", font_size);
  40.  
  41. // Format the count text
  42. count_text = sprintf(#, "%d", playback_count);
  43.  
  44. // Calculate text position (centered)
  45. str_width = 0;
  46. str_height = 0;
  47. gfx_measurestr(count_text, str_width, str_height);
  48. text_x = (gfx_w - str_width) * 0.5;
  49. text_y = (gfx_h - str_height) * 0.5;
  50.  
  51. // Draw the count
  52. gfx_x = text_x;
  53. gfx_y = text_y;
  54. gfx_drawstr(count_text);
  55.  
  56. // Draw label below the count
  57. label_font_size = font_size * 0.4;
  58. gfx_setfont(1, "Arial", label_font_size);
  59. label_text = "Playback Count";
  60. label_width = 0;
  61. label_height = 0;
  62. gfx_measurestr(label_text, label_width, label_height);
  63. label_x = (gfx_w - label_width) * 0.5;
  64. label_y = text_y + str_height + 5;
  65. gfx_x = label_x;
  66. gfx_y = label_y;
  67. gfx_drawstr(label_text);
Advertisement
Add Comment
Please, Sign In to add comment