Aller au contenu


Submitter

File Information

  • Submitted: juil. 13 2009 14:44
  • Last Updated: juil. 13 2009 14:44
  • File Size: 753,22 Ko
  • Views: 9
  • Downloads: 1

Download Xandu's Media Player v2 (WIP)

- - - - -



-------------------------------------------------XMP2 by Xandu--------------------------------------------------------------------

Mp3.stop()
lyricview = false
white = Color.new(255,255,255)
red = Color.new(255,0,0)
black = Color.new(0,0,0)
blue = Color.new(0,144,255)
blank = Color.new(0,0,0)
skyish = Color.new(241,249,251)
BG = Image.load("files/temp.png")

Pause = Image.load("files/pause.png")
Play = Image.load("files/play.png")

batlow = Image.load("files/batlow.png")
batmed = Image.load("files/batmed.png")
batful = Image.load("files/batful.png")
batchrg = Image.load("files/batchrg.png")


fonty = Font.load("MA")
fonty:setPixelSizes(15, 15)

imgtemp = nil

update = true

Mp3.init(1)

bar = Image.load("files/bar.png")

lib = Image.load("files/lib.png")
np = Image.load("files/np.png")

barx = 0

currentarea = 0
oldarea = 0
screenchange = 0
screenchange2 = 0
menuaccess = true
cursor = 5
cursor2 = 5

cdir = System.listDirectory("ms0:/PSP/MUSIC/")
cdirn = table.getn(cdir)


buffer = Image.createEmpty(480,272)



bigBG = Image.createEmpty(480,272)
bigBG:clear(skyish)


CHZ2i = Image.load("files/chz2.png")


CHZ = Image.load("files/chz.png")


playing = false
showit = true



lyric = 0

y = 0
x = 0

function playwheel()


NX = pad:analogX()
NY = pad:analogY()



if NX <= 127 and NX >= 0 and NY <= -128 and NY <= 0 then
currentarea = 1


end


if NX <= 127 and NX >= 0 and NY <= 127 and NY >= 0 then
currentarea = 2
end

if NX <= -128 and NX <= 0 and NY <= 127 and NY >= 0 then
currentarea = 3
end

if NX <= -128 and NX <= 0 and NY <= -128 and NY <= 0 then
currentarea = 4
end



if currentarea == oldarea-1 then
cursor = cursor -1

end

if currentarea == oldarea+1 then
cursor = cursor +1

end



end



function graphicsPrint(text)
  for i = 1, string.len(text) do
  char = string.sub(text, i, i)
  if char == "\n" then
  y = y + 8
  x = 0
  elseif char ~= "\r" then
  screen:print(x, y, char, white)
  x = x + 8
  end
  end


end

function graphicsPrintln(text)
  graphicsPrint(text .. "\n")
end



asd = PngFont.load("wd copy.png", 22, 20)
System.currentDirectory("ms0:/PSP/MUSIC/")


screen1b = 1 + screenchange
screen1e = 15

screen1b2 = 1 + screenchange2
screen1e2 = 16



playcheck = false

mode = "none"


function center(y,text,color)
  local length = string.len(text)
  local x = 240 - ((length*8)/2)
  buffer:fontPrint(fonty,x,y,text,color)
end

function centerB(y,text,color)
  local length = string.len(text)
  local x = 240 - ((length*8)/2)
  buffer:fontPrint(fonty,x+1,y,text,color)
end



function ULTRABUFFER()
buffer:clear()
buffer:blit(0,0,bigBG)
buffer:blit(0,0,BG)
buffer:blit(430,5,batimg)
buffer:fontPrint(fonty,210,20, "Now Playing", black)
buffer:blit(5,5,Play)


if imgp == true then
  buffer:blit(20,126-IMg:height()/2-20,IMg,false)


  buffer:fontPrint(fonty,150,80, artist, black)
  buffer:fontPrint(fonty,151,80, artist, black)
  buffer:fontPrint(fonty,150,100, album, black)
  buffer:fontPrint(fonty,150,120, title, black)

end

if imgp== false then

  center(80, artist, black)
  centerB(80, artist, black)
  center(100, album, black)
  center(120, title, black)

end

end

function mp3play()


if menuaccess == true then


if pad:up() and not oldpad:up() and cursor > 1+3 then  cursor = cursor - 1  end
--if pad:left() and not oldpad:left() and cursor > 1+3+6 then update = true cursor = cursor -6 end

if cdirn > 13 then


if pad:down() and not oldpad:down() and cursor <= 14 then  cursor = cursor + 1 end

if pad:right() and not oldpad:right() and cursor <= 14 then  cursor = cursor + 6 end


end

if cdirn < 13 then

if pad:down() and not oldpad:down() and cursor <= cdirn+3 then  cursor = cursor + 1 end
end



if cursor >= screen1e then
screenchange = screenchange + 1
cursor = cursor - 1
if screenchange > cdirn-15 then screenchange = cdirn-14 end
end



if cursor <= 4 then
screenchange = screenchange - 1
cursor = cursor + 1
if screenchange > cdirn-15 then screenchange = cdirn-14 end
end


if screenchange < 0 then screenchange = 0 end




CHZ2 = {}
CHZ2 = { x = 10, y = 18*cursor -10, img = CHZ2i}

  screen:blit(0,0,BG)
screen:blit(430,5,batimg)

screen:blit(CHZ2.x,CHZ2.y,CHZ2.img)
screen:pngFontPrint(asd,220, 8,"Library",black,false)


if cdirn > 13 then
for i = 1, 11 do

xy = 0
screen:pngFontPrint(asd,10, 10+ i*18+32,cdir[i+screenchange+1].name,black,false)



screen:pngFontPrint(asd,CHZ2.x,CHZ2.y-2,cdir[cursor-2+screenchange+xy].name,white,false)


end
end



if cdirn < 13 then
for i = 1, cdirn do
xy = -1
screen:print(10, 20+ i*12+25,cdir[i+screenchange].name,black)
screen:print(CHZ2.x,CHZ2.y,cdir[cursor-2+screenchange+xy].name,white)

end
end




if pad:cross() then
  if cdir[cursor-2+screenchange+xy].directory then
  newPath = "ms0:/PSP/MUSIC/"..cdir[cursor-2+screenchange+xy].name.."/"
  if System.listDirectory(newPath) ~= nil then
  cdir = System.listDirectory(newPath)
  cdirn = table.getn(cdir)
  System.currentDirectory(newPath)
  cursor = 5
  end
  end
end


if pad:circle() and not oldpad:circle() then

update = true





if string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -3)) == ".it" or string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".s3m" or string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".mod" or string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".mtm"  then

mode = "music"


title = cdir[cursor-2+screenchange+xy].name, -4
artist = ""
album = ""

Music.playFile(System.currentDirectory().."/"..cdir[cursor-2+screenchange+xy].name, true)

ULTRABUFFER()

playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true


--bigBG:clear(skyish)

pstate = 0



elseif string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".wav" then

mode = "wav"

title = cdir[cursor-2+screenchange+xy].name
artist = ""
album = ""

wave = Sound.load(System.currentDirectory().."/"..cdir[cursor-2+screenchange+xy].name, true)
local sound = wave
wavmusic = sound:play()

id3tag = {filename = ""..cdir[cursor-2+screenchange+xy].name, title = "", artist = "", album = ""}


ULTRABUFFER()

playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true

--bigBG:clear(skyish)

pstate = 0



elseif string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".mp3" then

mode = "mp3"

Mp3.load(System.currentDirectory().."/"..cdir[cursor-2+screenchange+xy].name)


title = cdir[cursor-2+screenchange+xy].name
artist = ""
album = ""

id3tag = {filename = System.currentDirectory().."/"..cdir[cursor-2+screenchange+xy].name, title = "", artist = "", album = ""}
id3v1(id3tag)
searchpng(id3tag)
lyrics2(id3tag)


ULTRABUFFER()


playstate = "play"

Mp3.play()
playcheck = true
System.sleep(31)

menuaccess = false
showit = true
playcheck = true

--bigBG:clear(skyish)

pstate = 0




elseif string.lower(string.sub(cdir[cursor-2+screenchange+xy].name, -4)) == ".ogg" then
--Ogg.init(1)
mode = "ogg"

title = cdir[cursor-2+screenchange+xy].name
artist = ""
album = ""

Ogg.load(System.currentDirectory().."/"..cdir[cursor-2+screenchange+xy].name)

id3tag = {filename = ""..cdir[cursor-2+screenchange+xy].name, title = "", artist = "", album = ""}

ULTRABUFFER()

playstate = "play"
Ogg.play()
playcheck = true
System.sleep(31)

menuaccess = false
showit = true
playcheck = true

--bigBG:clear(skyish)

pstate = 0

else
buffer:clear()
buffer:blit(0,0,bigBG)
buffer:blit(0,0,BG)
buffer:blit(430,5,batimg)
buffer:fontPrint(fonty,210,20, "Now Playing", black)
pstate = 0

  buffer:fontPrint(fonty,150,130, "The data cannot be played.", black)
  buffer:fontPrint(fonty,151,130, "The data cannot be played.", black)

  buffer:fontPrint(fonty,150,150, "The format is not supported.", black)
  buffer:fontPrint(fonty,151,150, "The format is not supported.", black)
  
  
buffer:blit(5,5,Play)
playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true



end







end




end

end












imgtemp = Image.createEmpty(170,150)

imgp = false





lyricpresent = false

function lyrics2(lyr)

file = io.open(lyr.filename,"r")
file:seek("set")

thelyr = file:read(10000)

found = string.find(thelyr,"USLT")

if found then
find1 = string.sub(thelyr,found+15)
find2 = string.find(find1, "\0")
luric = string.sub(find1,0,find2)
lyricpresent = true
end



file:close()


end





function searchpng(filezz)

  file = io.open(filezz.filename,"r")
  file:seek("set")
  dataZ = file:read(100000)
  file:close()




  theimg = string.find(dataZ,"image/png") start = 12 thing = 7
  if not theimg then theimg = string.find(dataZ,"image/jpg") start = 12 thing =0 end
  if not theimg then theimg = string.find(dataZ,"image/jpeg") start = 13 thing =0 end
  begining = nil
  ending = nil
  imagedata = nil
if theimg then
  begining = string.sub(dataZ,theimg+start)
  ending = string.find(begining,"IEND")




  if thing ==7 and find2 then
  imagedata = string.sub(begining,0,ending+7)
  end
  if thing == 0 then
  imagedata = string.sub(begining,0,ending)
  end


  if imagedata then

  imgtemp2 = Image.loadFromMemory(imagedata)


  scale(115,110,imgtemp2)
  imgp = true
  else imagedata = nil

  end

  end
end






function id3v1(tag)


  file = io.open(tag.filename,"r")
  file:seek("end", -128)
  data1 = file:read("*a")


  magic = string.sub(data1, 0, 3)
  if magic~="TAG" then tag.title = tag.filename tag.artist = "-" tag.album = "-" data = nil return 0 end

  title = string.sub(data1, 4, 33)
  artist = string.sub(data1, 34, 63)
  album = string.sub(data1, 64, 93)

  data = nil





end






function scale(X, Y,IMG)

IMg = Image.createEmpty(X, Y)
for x = 1, X do
for y = 1, Y do
IMg:blit(x,y , IMG,math.floor(x*(IMG:width()/X)),math.floor(y*(IMG:height()/Y)), 1,1)
end
end
return IMg
end














playstate = "stop"

while true do
screen:clear(skyish)
pad = Controls.read()
barx = barx + 0.001
screen:blit(barx,200,bar)
battery = System.powerGetBatteryLifePercent()

if battery >= 0 and battery < 49 then batimg = batlow end
if battery >= 50 and battery < 79 then batimg = batmed end
if battery >= 80 and battery <= 100 then batimg = batful end

if System.powerIsBatteryCharging() == true then
batimg = batchrg
end

if menuaccess == true then
screen:clear()
screen:blit(0,0,bigBG)
--screen:blit(0,0,BG)
screen:blit(430,5,batimg)
end


mp3play()
playwheel()







if showit == true then






screenie = nil

if playcheck == true then
screen:blit(0,0,buffer)





if mode== "mp3" then
mp3time = Mp3.getTime()
buffer:pngFontPrint(asd,100,230,mp3time,black)
end


controlchk = false

lolhax = cursor-2+screenchange+xy

currentsong = lolhax + pstate


if pad:right() or Mp3.endOfStream() and currentsong < cdirn then
update = true
imgp = false
imgtemp:clear()
pstate = pstate + 1
playcheck = false
playstate = "stop"
controlchk = true
else
pstate = pstate
controlchk = false
end

if pad:left() then
update = true
imgp = false
imgtemp:clear()
pstate = pstate - 1
playcheck = false
playstate = "stop"
controlchk = true
end


if controlchk == true then

if mode == "mp3" then
screen.waitVblankStart(10)
Mp3.stop()
screen.waitVblankStart(10)

end

if mode == "ogg" then
screen.waitVblankStart(10)
Ogg.stop()
screen.waitVblankStart(10)
--Ogg.init(1)
end

if mode == "music" then
screen.waitVblankStart(10)
Music.stop()
screen.waitVblankStart(10)
end

if mode == "wav" then
screen.waitVblankStart(10)
wavmusic:stop()
screen.waitVblankStart(10)
end



if string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".mp3" then

Mp3.load(System.currentDirectory().."/"..cdir[lolhax + pstate].name)

title = cdir[lolhax + pstate].name
artist = ""
album = ""

Mp3.play()
id3tag = {filename = System.currentDirectory().."/"..cdir[lolhax + pstate].name, title = "", artist = "", album = ""}
id3v1(id3tag)
searchpng(id3tag)

ULTRABUFFER()


playstate = "play"

playcheck = true
System.sleep(1)

menuaccess = false
showit = true
playcheck = true


elseif string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".wav" then

mode = "wav"

title = cdir[lolhax + pstate].name
artist = ""
album = ""

wave = Sound.load(System.currentDirectory().."/"..cdir[lolhax + pstate].name, true)
local sound = wave
wavmusic = sound:play()

id3tag = {filename = ""..cdir[lolhax + pstate].name, title = "", artist = "", album = ""}
ULTRABUFFER()
playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true






elseif string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".ogg" then
--Ogg.init(1)
mode = "ogg"

title = cdir[lolhax + pstate].name
artist = ""
album = ""

Ogg.load(System.currentDirectory().."/"..cdir[lolhax + pstate].name)

id3tag = {filename = ""..cdir[lolhax + pstate].name, title = "", artist = "", album = ""}

ULTRABUFFER()

playstate = "play"
Ogg.play()
playcheck = true
System.sleep(31)

menuaccess = false
showit = true
playcheck = true



elseif string.lower(string.sub(cdir[lolhax + pstate].name, -3)) == ".it" or string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".s3m" or string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".mod" or string.lower(string.sub(cdir[lolhax + pstate].name, -4)) == ".mtm"  then

mode = "music"

title = cdir[lolhax + pstate].name
artist = ""
album = ""

Music.playFile(System.currentDirectory().."/"..cdir[lolhax + pstate].name, true)

ULTRABUFFER()

playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true


else
buffer:clear()
buffer:blit(0,0,bigBG)
buffer:blit(0,0,BG)
buffer:blit(430,5,batimg)
buffer:fontPrint(fonty,210,20, "Now Playing", black)


  buffer:fontPrint(fonty,150,130, "The data cannot be played.", black)
  buffer:fontPrint(fonty,151,130, "The data cannot be played.", black)

  buffer:fontPrint(fonty,150,150, "The format is not supported.", black)
  buffer:fontPrint(fonty,151,150, "The format is not supported.", black)


buffer:blit(5,5,Play)
playstate = "play"
playcheck = true
System.sleep(31)

menuaccess = false
showit = true


end







end




end















if pad:triangle() and not oldpad:triangle() then
lyricview = not lyricview
end

if lyricview == true and lyricpresent == true then
lyry = 80

buffer:clear()
buffer:blit(0,0,bigBG)
buffer:blit(0,0,BG)
buffer:blit(430,5,batimg)
buffer:fontPrint(fonty,210,20, "Lyrics", black)
buffer:blit(5,5,Play)

buffer:fontPrint(fonty,10,lyry,luric,black)

if pad:down() then
lyry = lyry - 1
end

if pad:up() then
lyry = lyry + 1
end


end


--[[if lyricview == false then
ULTRABUFFER()
end     ]]




















if pad:cross() and playstate == "play" then
update = true

if mode == "mp3" then
Mp3.pause()
playstate = "pause"
end

if mode == "ogg" then
Ogg.pause()
playstate = "pause"
end

if mode == "music" then
Music.pause()
playstate = "pause"
end

if mode == "wav" then
wavmusic:stop()
playstate = "stop"
end

end




if pad:circle() and playstate == "pause" then
update = true
if mode == "mp3" then
Mp3.play()
end

if mode == "ogg" then
Ogg.play()
end

if mode == "music" then
Music.resume()
end

if mode == "wav" then
wavmusic:play()
end

playstate = "play"


end








end










if pad:l() and menuaccess == true then
update = true

menuaccess = false
showit = true



end




if pad:r() and menuaccess == false then    -- 1st -->
update = true



imgp = false

menuaccess = true

showit = false

if playcheck == true then

if mode == "mp3" then
Mp3.stop()
screen.waitVblankStart(10)
imgtemp:clear()
end

if mode == "ogg" then
Ogg.stop()
end

playcheck = false
playstate = "stop"

if mode == "music" then
Music.stop()
end

if mode == "wav" then
wavmusic:stop()
end


end

end









if pad:select() then

if playcheck == true then

if mode == "mp3" then
Mp3.stop()
imgtemp:clear()
end

if mode == "ogg" then
Ogg.stop()
end


if mode == "music" then
Music.stop()
end

if mode == "wav" then
wavmusic:stop()
end



playcheck = false
playstate = "stop"
end
break
end


if pad:square() then

Image:save( "snap.png" )

if playcheck == true then

if mode == "mp3" then
Mp3.stop()
imgtemp:clear()
end

if mode == "ogg" then
Ogg.stop()
end


if mode == "music" then
Music.stop()
end

if mode == "wav" then
wavmusic:stop()
end

playcheck = false
playstate = "stop"
end


end

if pad:select() then
if playcheck == true then

if mode == "mp3" then
Mp3.stop()
imgtemp:clear()
end

if mode == "ogg" then
Ogg.stop()
end


if mode == "music" then
Music.stop()
end

if mode == "wav" then
wavmusic:stop()
end

playcheck = false
playstate = "stop"
end

break end

oldpad = pad




oldarea = currentarea
screen.waitVblankStart()
screen.flip()

end








Other files you may be interested in ..





  • 4 891 Total Files
  • 401 Total Categories
  • 13 Total Authors
  • 294 641 Total Downloads
  • Xbox Backup Creator Latest File
  • Razkar Latest Submitter