local Enable_MP3Player = get_aircraft_property("MP3Player")
if Enable_MP3Player~=1 then
	return
end

SUB_PAGE_VAL        = SubPageVal
local mp3_simple = AddSimple(nil,nil,nil,Page4_sim)
local MFD_IND_TEX_PATH        = LockOn_Options.script_path .. "../Textures/MFD/"  --定义屏幕贴图路径
local mp3_symbol_material     = MakeMaterial(MFD_IND_TEX_PATH.."mp3_symbols.dds", {255,255,255,255})
local modPath=LockOn_Options.script_path.."../../"

local songListSim = AddSimple(nil,{0,0.3*height},nil,mp3_simple)
-- AddBox(nil,0.5*width,0.7*height,nil,nil,MakeMaterial(nil,{64,64,64,128}),nil,nil,songListSim,{'MP3_MUSIC_LIST_ENABLE'},{
--     {AnimalControllor.parameterInRange,0,1.9,2.1}
-- })
AddText(nil,nil,'unicode_cn_green',{0,0.18*height},nil,DEFAULT_FONT_SIZE[5],nil,nil,songListSim,{'%s'},{'MP3_NAME_LAST_TEXT','MP3_MUSIC_LIST_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,1.9,2.1},
})

AddText(nil,nil,'unicode_cn_white',{0,0.0*height},nil,DEFAULT_FONT_SIZE[5],nil,nil,songListSim,{'%s'},{'MP3_NAME_TEXT','MP3_MUSIC_LIST_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,1.9,2.1},
})

AddText(nil,nil,'unicode_cn_green',{0,-0.18*height},nil,DEFAULT_FONT_SIZE[5],nil,nil,songListSim,{'%s'},{'MP3_NAME_NEXT_TEXT','MP3_MUSIC_LIST_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,1.9,2.1},
})

local disk_sim = AddSimple(nil,nil,nil,mp3_simple)

--磁头


local diskRot_sim = AddSimple(nil,{0,0.0*height},nil,disk_sim,{'MP3_DISK_ROT'},{
    {AnimalControllor.rotateUsingParameter,0,-math.rad(1)}
})
AddCircle(nil,0.5*width,0.35*width,360,72,nil,nil,'DBG_BLACK',nil,nil,diskRot_sim,{'MP3_LRC_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
})--黑胶
AddCircle(nil,0.35*width,0.1*width,360,72,nil,nil,'DBG_WHITE',REWRITE_LEVEL,DEFAULT_MASK_LEVEL+1,diskRot_sim,{'MP3_LRC_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
},true)--专辑
AddCircle(nil,0.35*width,0.1*width,360,72,nil,nil,'DBG_WHITE',INCREASE_IF_LEVEL,DEFAULT_MASK_LEVEL+1,diskRot_sim,{'MP3_LRC_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
},true)--专辑

dofile(LockOn_Options.script_path.."Systems/mp3List.lua")

for k, v in pairs(mp3List) do
    local imgPath
    if v.img then
        imgPath = modPath.."sounds/effects/Mp3Player/img/"..v.img
    else
        imgPath = modPath.."sounds/effects/Mp3Player/img/"..string.gsub(v.name,'.mp3','.jpg')
    end
    AddTexture(nil,{{-0.35*width,0.35*width},{0.35*width,0.35*width},{0.35*width,-0.35*width},{-0.35*width,-0.35*width}},
    {0,1,2,2,3,0},Texure_coord_gen(0,0,1024,1024,1024,1024),MakeMaterial(imgPath,{128,128,128,255}),nil,nil,nil,DEFAULT_MASK_LEVEL+2,diskRot_sim,
    {'MP3_LRC_ENABLE','MP3_Index'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1},
    {AnimalControllor.parameterInRange,1,k-0.1,k+0.1},
},true)
end
AddCircle(nil,0.1*width,0.015*width,360,72,nil,nil,'DBG_RED',nil,nil,diskRot_sim,{'MP3_LRC_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
})
AddCircle(nil,0.015*width,0.0*width,360,72,nil,nil,'DBG_BLACK',nil,nil,diskRot_sim,{'MP3_LRC_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
})

local magneticHeadSim = AddSimple(nil,{0, height*0.85},{0,0},disk_sim,{'MAGNETIC_HEADER','MP3_LRC_ENABLE'},{
    {AnimalControllor.rotateUsingParameter,0,-math.rad(20)},
    {AnimalControllor.parameterInRange,1,-0.1,0.1}
})

local lrc_sim = AddSimple(nil,{0,0.3*height},nil,mp3_simple)

AddText(nil,nil,'unicode_cn_green',{0,0.05*height},Align.CB,DEFAULT_FONT_SIZE[5],nil,nil,lrc_sim,{'%s'},{'MP3_LAST_LRC_TEXT','MP3_LRC_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,0.9,1.1},
})

AddText(nil,nil,'unicode_cn_white',{0,0.0*height},nil,DEFAULT_FONT_SIZE[5],nil,nil,lrc_sim,{'%s'},{'MP3_CUR_LRC_TEXT','MP3_LRC_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,0.9,1.1},
})

AddText(nil,nil,'unicode_cn_green',{0,0.05*height},Align.CT,DEFAULT_FONT_SIZE[5],nil,nil,lrc_sim,{'%s'},{'MP3_NEXT_LRC_TEXT','MP3_LRC_ENABLE'},{
    {AnimalControllor.textUsingParameter,0},
    {AnimalControllor.parameterInRange,1,0.9,1.1},
})

local timelineSim = AddSimple(nil,{0,-0.75*height},nil,mp3_simple)

AddText(nil,nil,'unicode_cn_white',{-0.8*width,0.0*height},Align.RC,DEFAULT_FONT_SIZE[6],nil,nil,timelineSim,{'%s'},{'MP3_PLAYBACK_PRO_TEXT'},{
    {AnimalControllor.textUsingParameter,0}
})
AddText(nil,nil,'unicode_cn_white',{0.8*width,0.0*height},Align.LC,DEFAULT_FONT_SIZE[6],nil,nil,timelineSim,{'%s'},{'MP3_SONG_LENGTH_TEXT'},{
    {AnimalControllor.textUsingParameter,0}
})



AddSimpleLine(nil,0.005*width,{{-0.78*width,0},{0.78*width,0}},nil,nil,'DBG_WHITE',nil,nil,timelineSim)--进度条

AddCircle(nil,0.02*width,0,360,18,{-0.78*width,0},nil,'DBG_WHITE',nil,nil,timelineSim,{'MP3_PLAYBACK_PRO_BAR'},{
    {AnimalControllor.moveLeftRightUsingParameter,0,0.0873}
})

local playBtnSim = AddSimple(nil,{0,-0.9*height},nil,mp3_simple)
--播放符号
AddMeshPoly(nil,{
    {-0.05*width,0.07*width},{-0.05*width,-0.07*width},{0.05*width,0}
},{0,1,2},nil,nil,'DBG_WHITE',nil,nil,playBtnSim,{'MP3_PLAY_ENABLE'},{
    {AnimalControllor.parameterInRange,0,-0.1,0.1}
})
--暂停符号
AddMeshPoly(nil,{
    {-0.07*width,0.07*width},{-0.03*width,0.07*width},{-0.03*width,-0.07*width},{-0.07*width,-0.07*width},
    {0.07*width,0.07*width},{0.03*width,0.07*width},{0.03*width,-0.07*width},{0.07*width,-0.07*width},
},{0,1,2,2,3,0,4,5,6,6,7,4},
nil,nil,'DBG_WHITE',nil,nil,playBtnSim,{'MP3_PLAY_ENABLE'},{
    {AnimalControllor.parameterInRange,0,0.9,1.1}
})
--下一首符号
AddMeshPoly(nil,{
    {0.05*width,0.05*width},{0.03*width,0.05*width},{0.03*width,-0.05*width},{0.05*width,-0.05*width},
    {0.03*width,0.0*width},{-0.05*width,-0.05*width},{-0.05*width,0.05*width},
},{0,1,2,2,3,0,4,5,6},
{0.2*width,0},nil,'DBG_WHITE',nil,nil,playBtnSim,{'MP3_NEXT_CLICK'},{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,1,1,1,1}
})
--上一首符号
AddMeshPoly(nil,{
    {-0.05*width,0.05*width},{-0.03*width,0.05*width},{-0.03*width,-0.05*width},{-0.05*width,-0.05*width},
    {-0.03*width,0.0*width},{0.05*width,-0.05*width},{0.05*width,0.05*width},
},{0,1,2,2,3,0,4,5,6},
{-0.2*width,0},nil,'DBG_WHITE',nil,nil,playBtnSim,{'MP3_NEXT_CLICK'},{
    {AnimalControllor.changeColorWhenParameterEqualToNumber,0,1,1,1,1}
})

AddTexture(nil,{{-0.05*width,0.05*height},{0.55*width,0.05*height},{0.55*width,-0.45*height},{-0.05*width,-0.45*height}},{0,1,2,2,3,0},
    Texure_coord_gen(0,494,429,349,1024,1024),mp3_symbol_material,nil,{-0,0},nil,nil,magneticHeadSim
)