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_Toggle_Queue = true
local JBC_Play_Pause = true
local JBC_Is_Being_Plaued = false

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


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
