Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Loads up the file
- test = JPGV.load(System.currentDirectory().."/output.jpgv")
- -- Calculates total seconds for time
- tot_time_sec = math.ceil(JPGV.getSize(test) / JPGV.getFPS(test))
- tot_time_min = 0
- while (tot_time_sec >= 60) do
- tot_time_sec = tot_time_sec - 60
- tot_time_min = tot_time_min + 1
- end
- -- loads jpgv modules + sets color for text
- Sound.init()
- JPGV.start(test,NO_LOOP)
- oldpad = Controls.read()
- timer = Timer.new()
- white = Color.new(255,255,255)
- -- Actual playing code
- while true do
- Screen.waitVblankStart()
- Screen.refresh()
- -- Clears top screen and loads the video in the bottom.
- Screen.clear(BOTTOM_SCREEN)
- JPGV.draw(0,0,test,TOP_SCREEN)
- pad = Controls.read()
- -- Controls exit button. Defaults to A
- if (Controls.check(pad,KEY_A)) then
- Sound.term()
- System.exit()
- end
- -- Shows info about current video
- Screen.debugPrint(0,100,"Infos:",white,BOTTOM_SCREEN)
- -- Shows FPS
- Screen.debugPrint(0,114,"FPS: "..JPGV.getFPS(test),white,BOTTOM_SCREEN)
- cur_time_sec = math.ceil(JPGV.getFrame(test) / JPGV.getFPS(test))
- cur_time_min = 0
- while (cur_time_sec >= 60) do
- cur_time_sec = cur_time_sec - 60
- cur_time_min = cur_time_min + 1
- end
- -- Shows time
- if (cur_time_sec < 10) then
- Screen.debugPrint(0,128,"Time: " .. cur_time_min .. ":0" .. cur_time_sec .. " / " .. tot_time_min .. ":" .. tot_time_sec,white,BOTTOM_SCREEN)
- else
- Screen.debugPrint(0,128,"Time: " .. cur_time_min .. ":" .. cur_time_sec .. " / " .. tot_time_min .. ":" .. tot_time_sec,white,BOTTOM_SCREEN)
- end
- -- Shows Samplerate
- Screen.debugPrint(0,142,"Samplerate: "..JPGV.getSrate(test),white,BOTTOM_SCREEN)
- -- Progress bar (Broken)
- -- percentage = math.ceil((JPGV.getFrame(test) * 100) / JPGV.getSize(test))
- -- Screen.debugPrint(0,200,"Percentage: " ..percentage .. "%",white,BOTTOM_SCREEN)
- -- Screen.fillEmptyRect(2,398,214,234,white,BOTTOM_SCREEN)
- -- move = ((394 * percentage) / 100)
- -- Screen.fillRect(3,3 + move,215,233,white,BOTTOM_SCREEN)
- -- Controls pause button
- if (Controls.check(pad,KEY_B)) and not (Controls.check(oldpad,KEY_B)) then
- if (JPGV.isPlaying(test)) then
- JPGV.pause(test)
- else
- JPGV.resume(test)
- end
- end
- Screen.flip()
- oldpad = pad
- end
- -- Credits to: Rinnegatamante for the original JPGV.lua
- -- ihaveamac for letting me localize output.jpgv
- -- ihaveamac and Rinnegatamante (again) for helping me fix the code
- -- ev1l0rd for the guide
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement