assert(LibStub, "Missing dependency: LibStub");
local JBCLib_M = "JBClib"
local JBCLib_m = 1 -- Bump on changes


local JBCLib = LibStub:NewLibrary(JBCLib_M , JBCLib_m)
if not JBCLib then return end

function JBCLib.fun()
print("lmao")
end




local JBC_Names_Playlist = {

}
local JBC_Duration_Playlist = {

}
local JBC_ID_Playlist = {

}



local JBC_Stored_lists = {
	
}



local JBC_Toggle_Queue = true
local JBC_Play_Pause = true
local JBC_Is_Being_Plaued = false
local JBC_Raid_Com = true

function JBCLib:ToggleQueue()
 if JBC_Toggle_Queue == true then
    JBC_Toggle_Queue = false
	print("   [|cFF00FF00JukeBox Coin|r] - |c00ff0000Queue Status: Off|r")
	JBCLib:EmptyQueue()
 elseif JBC_Toggle_Queue == false then
    JBC_Toggle_Queue = true
	print("   [|cFF00FF00JukeBox Coin|r] - |c0000ff00Queue Status: On|r")
 end
 return JBC_Toggle_Queue
end



----------------------------------------------
----------------------------------------------

---TMP FUNCTION
function JBCLib:LoadQueue(name,ID,duration)
JBC_Names_Playlist = name
JBC_Duration_Playlist = duration
JBC_ID_Playlist = ID
end

---TMP FUNCTION
function JBCLib:ReturnQueue()
return JBC_Names_Playlist, JBC_Duration_Playlist, JBC_ID_Playlist
end



function JBCLib:Returnlist()
	return JBC_Stored_lists
end

function JBCLib:Storelist(list)
 --JBC_Stored_lists = deepCopy(list)
   JBC_Stored_lists = list
end

function JBCLib:AppendToSaves(list,name)
	tinsert(JBC_Stored_lists,list)
end

----------------------------------------------
----------------------------------------------

function JBCLib:CheckRaidCom()
 return JBC_Raid_Com
end
function JBCLib:SetRaidCom(status)
  JBC_Raid_Com = status
end


function JBCLib:CheckFlag()
 return JBC_Toggle_Queue
end

function JBCLib:CheckPlay()
 return JBC_Is_Being_Plaued
end

function JBCLib:SetPlay(status)
  JBC_Is_Being_Plaued = status
end

function JBCLib:PlayPause()
 if JBC_Play_Pause == true then
   JBC_Play_Pause = false
	print("   [|cFF00FF00JukeBox Coin|r] - |c00ff0000Playlist Paused|r")
 elseif JBC_Play_Pause == false then
    JBC_Play_Pause = true
	print("   [|cFF00FF00JukeBox Coin|r] - |c0000ff00Playing now|r")
 end
 return JBC_Play_Pause

end

function JBCLib:ReturnPlayStatus()
 return JBC_Play_Pause
end


function JBCLib:EmptyQueue()
  JBC_Names_Playlist = {}
  JBC_Duration_Playlist = {}
  JBC_ID_Playlist = {}
end

function JBCLib:ReturnDuration(index)
   index = index or 1
    if JBCLib:CheckQueueLenght() == 0 then
	  return 0
 else
   return JBC_Duration_Playlist[index]
  end
end
function JBCLib:ReturnID(index)
   index = index or 1
    if JBCLib:CheckQueueLenght() == 0 then
	  return nil
 else
   return JBC_ID_Playlist[index]
  end
end
function JBCLib:ReturnName(index)
   index = index or 1
    if JBCLib:CheckQueueLenght() == 0 then
	  return nil
 else
   return JBC_Names_Playlist[index]
  end
end


function JBCLib:CheckQueueLenght()
  if table.getn( JBC_Names_Playlist ) == table.getn( JBC_ID_Playlist ) and table.getn( JBC_Names_Playlist ) == table.getn( JBC_Duration_Playlist ) then
     return table.getn( JBC_Names_Playlist )
  else 
     JBCLib:EmptyQueue()
     return 0
  end
end

function JBCLib:PrintQueue()
   if JBCLib:CheckQueueLenght() == 0 then
    print("Empty Queue")
   else
    for index=1 , JBCLib:CheckQueueLenght() do
	print(JBC_Duration_Playlist[index], " ", JBC_ID_Playlist[index], " ",JBC_Names_Playlist[index] )
   end
   end
end
  
function JBCLib:AddToQueue(name,ID,duration)
table.insert(JBC_Names_Playlist, name)
table.insert(JBC_ID_Playlist, ID)
table.insert(JBC_Duration_Playlist, duration)
end

function JBCLib:RemoveFromQueue(line)
   line = line or table.getn( JBC_Names_Playlist )
   table.remove(JBC_Names_Playlist, line  )
   table.remove(JBC_ID_Playlist, line)
   table.remove(JBC_Duration_Playlist,line)
end

function JBCLib:PlayFromQueue()
   if JBCLib:CheckQueueLenght() == 0 then
   else
   PlayMusic(JBC_ID_Playlist[1])
   JBCLib:RemoveFromQueue(1)
   end
end



local JBC_First_Playlist = {
	{
		["name"] = "IntroLitch",
		["content"] = {
			{
				["ID"] = 3885852,
				["text"] = "shadowlands/mus_90_rtc_ddr",
				["index"] = 1,
				["duration"] = 68.88,
			}, -- [1]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 2,
				["duration"] = 64,
			}, -- [2]
		},
	},
	{
		["name"] = "Heroic",
		["content"] = {
			{
				["ID"] = 575700,
				["text"] = "cataclysm/mus_43_warships_hero_01",
				["index"] = 1,
				["duration"] = 90.288,
			}, -- [1]
			{
				["ID"] = 575701,
				["text"] = "cataclysm/mus_43_warships_uu01",
				["index"] = 2,
				["duration"] = 66.288,
			}, -- [2]
			{
				["ID"] = 575694,
				["text"] = "cataclysm/mus_43_thrallearthwarder_uu01",
				["index"] = 3,
				["duration"] = 61.992,
			}, -- [3]
			{
				["ID"] = 575695,
				["text"] = "cataclysm/mus_43_thrallearthwarder_uu02",
				["index"] = 4,
				["duration"] = 42.288,
			}, -- [4]
			{
				["ID"] = 575696,
				["text"] = "cataclysm/mus_43_thrallearthwarder_uu03",
				["index"] = 5,
				["duration"] = 47.544,
			}, -- [5]
		},
	},
	{
		["name"] = "DarkTension",
		["content"] = {
			{
				["ID"] = 575672,
				["text"] = "cataclysm/mus_43_fangsofthefathera_uu02",
				["index"] = 1,
				["duration"] = 99.648,
			}, -- [1]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 2,
				["duration"] = 64,
			}, -- [2]
			{
				["ID"] = 575674,
				["text"] = "cataclysm/mus_43_fangsofthefatherb_uu01",
				["index"] = 3,
				["duration"] = 77.208,
			}, -- [3]
			{
				["ID"] = 575680,
				["text"] = "cataclysm/mus_43_fangsofthefatherc_uu04",
				["index"] = 4,
				["duration"] = 63.648,
			}, -- [4]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 5,
				["duration"] = 64,
			}, -- [5]
			{
				["ID"] = 575691,
				["text"] = "cataclysm/mus_43_nightwalk_uu02",
				["index"] = 6,
				["duration"] = 60.048,
			}, -- [6]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 7,
				["duration"] = 64,
			}, -- [7]
			{
				["ID"] = 840466,
				["text"] = "mus_52_iotk_isleofthunder_general_walk_05",
				["index"] = 8,
				["duration"] = 73.95265,
			}, -- [8]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 9,
				["duration"] = 64,
			}, -- [9]
		},
	},
	{
		["name"] = "ChillAmbient",
		["content"] = {
			{
				["ID"] = 1272557,
				["text"] = "legion/mus_70_totems_h",
				["index"] = 1,
				["duration"] = 349.2963,
			}, -- [1]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 2,
				["duration"] = 30,
			}, -- [2]
			{
				["ID"] = 1080507,
				["text"] = "draenor/mus_60_coldmountain_duet_h",
				["index"] = 3,
				["duration"] = 156.2149,
			}, -- [3]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 4,
				["duration"] = 64,
			}, -- [4]
			{
				["ID"] = 1080408,
				["text"] = "draenor/mus_60_eagle_a",
				["index"] = 5,
				["duration"] = 127.1656,
			}, -- [5]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 6,
				["duration"] = 64,
			}, -- [6]
			{
				["ID"] = 1067555,
				["text"] = "draenor/mus_60_magnificentdesolation2_a1",
				["index"] = 7,
				["duration"] = 83.1088,
			}, -- [7]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 8,
				["duration"] = 64,
			}, -- [8]
			{
				["ID"] = 1061128,
				["text"] = "draenor/mus_60_mandown_a2",
				["index"] = 9,
				["duration"] = 60.456,
			}, -- [9]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 10,
				["duration"] = 64,
			}, -- [10]
			{
				["ID"] = 443290,
				["text"] = "mus_twilighthighlands_gn (1)_03",
				["index"] = 14,
				["duration"] = 69.0931,
			}, -- [11]
			{
				["ID"] = "Interface\\AddOns\\JukeboxCoin\\MyMusic\\U\\S.mp3",
				["text"] = "U\\S",
				["index"] = 15,
				["duration"] = 64,
			}, -- [12]
			{
				["ID"] = 1417371,
				["text"] = "mus_70_zone_suramar_sombre_walk_01",
				["index"] = 16,
				["duration"] = 66.3723,
			}, -- [13]
		},
	},
}

function JBCLib:ReturnFirstPlaylist()
	return JBC_First_Playlist
end


