Advertisement
ev1l0rd

index.lua

Feb 2nd, 2016
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. -- Loads up the file
  2. test = JPGV.load(System.currentDirectory().."/output.jpgv")
  3.  
  4. -- Calculates total seconds for time
  5. tot_time_sec = math.ceil(JPGV.getSize(test) / JPGV.getFPS(test))
  6. tot_time_min = 0
  7. while (tot_time_sec >= 60) do
  8.     tot_time_sec = tot_time_sec - 60
  9.     tot_time_min = tot_time_min + 1
  10. end
  11.  
  12. -- loads jpgv modules + sets color for text
  13. Sound.init()
  14. JPGV.start(test,NO_LOOP)
  15. oldpad = Controls.read()
  16. timer = Timer.new()
  17. white = Color.new(255,255,255)
  18.  
  19. -- Actual playing code
  20. while true do
  21.     Screen.waitVblankStart()
  22.     Screen.refresh()
  23.     -- Clears top screen and loads the video in the bottom.
  24.     Screen.clear(BOTTOM_SCREEN)
  25.     JPGV.draw(0,0,test,TOP_SCREEN)
  26.     pad = Controls.read()
  27.     -- Controls exit button. Defaults to A
  28.     if (Controls.check(pad,KEY_A)) then
  29.         Sound.term()
  30.         System.exit()
  31.     end
  32.     -- Shows info about current video
  33.     Screen.debugPrint(0,100,"Infos:",white,BOTTOM_SCREEN)
  34.     -- Shows FPS
  35.     Screen.debugPrint(0,114,"FPS: "..JPGV.getFPS(test),white,BOTTOM_SCREEN)
  36.     cur_time_sec = math.ceil(JPGV.getFrame(test) / JPGV.getFPS(test))
  37.     cur_time_min = 0
  38.     while (cur_time_sec >= 60) do
  39.         cur_time_sec = cur_time_sec - 60
  40.         cur_time_min = cur_time_min + 1
  41.     end
  42.     -- Shows time
  43.     if (cur_time_sec < 10) then
  44.         Screen.debugPrint(0,128,"Time: " .. cur_time_min .. ":0" .. cur_time_sec .. " / " .. tot_time_min .. ":" .. tot_time_sec,white,BOTTOM_SCREEN)
  45.     else
  46.         Screen.debugPrint(0,128,"Time: " .. cur_time_min .. ":" .. cur_time_sec .. " / " .. tot_time_min .. ":" .. tot_time_sec,white,BOTTOM_SCREEN)
  47.     end
  48.     -- Shows Samplerate
  49.     Screen.debugPrint(0,142,"Samplerate: "..JPGV.getSrate(test),white,BOTTOM_SCREEN)
  50.    
  51.     -- Progress bar (Broken)
  52. --  percentage = math.ceil((JPGV.getFrame(test) * 100) / JPGV.getSize(test))
  53. --  Screen.debugPrint(0,200,"Percentage: " ..percentage .. "%",white,BOTTOM_SCREEN)
  54. --  Screen.fillEmptyRect(2,398,214,234,white,BOTTOM_SCREEN)
  55. --  move = ((394 * percentage) / 100)
  56. --  Screen.fillRect(3,3 + move,215,233,white,BOTTOM_SCREEN)
  57.    
  58.     -- Controls pause button
  59.     if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) then
  60.         if (JPGV.isPlaying(test)) then
  61.             JPGV.pause(test)
  62.         else
  63.             JPGV.resume(test)
  64.         end
  65.     end
  66.     Screen.flip()
  67.     oldpad = pad
  68. end
  69.  
  70. -- Credits to: Rinnegatamante for the original JPGV.lua
  71. -- ihaveamac for letting me localize output.jpgv
  72. -- ihaveamac and Rinnegatamante (again) for helping me fix the code
  73. -- ev1l0rd for the guide
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement