local pauser = reaper.GetToggleCommandStateEx(0, 40367)
local stoper = reaper.GetToggleCommandStateEx(0, 1016)
local player = reaper.GetToggleCommandStateEx(0, 1007)
local recording = reaper.GetToggleCommandStateEx(0, 1013)

--mono = reaper.GetProjectLength()
mono =     reaper.GetCursorPosition();
--mono = mena - awad

function SplitFilename(strFilename)
  return string.match(strFilename, "(.-)([^.]-[.-])([^.]+)$")

end


if pauser == 0 then
local OOO1 =  math.floor( 1 * mono  / 60 /60 ) 
local OOO2 =  math.floor( 1 * mono  / 60% 60 ) 
local OOO3 =  math.floor( 100 * (mono % 60 ) ) / 100 


if (tonumber(OOO1) == nil) then
 hour = ""
elseif (tonumber(OOO1) == 0) then
 hour = ""
OOO1 = ""
elseif (tonumber(OOO1) == 1) then
hour = "Hour"
 else
hour = "Hours"
 end
if (tonumber(OOO2) == nil) then
 min = ""
elseif (tonumber(OOO2) == 0) then
 min = ""
OOO2 = ""
elseif (tonumber(OOO2) == 1) then
 min = "Minute"
 else
 min = "Minutes"
 end

if (tonumber(OOO3) == nil)  then
 sec = ""
elseif  (tonumber(OOO3) == 1)  then
 sec = ""
OOO3 = ""
elseif  (tonumber(OOO3) == 1)  then
 sec = "Second"
 else
 sec = "Seconds"
 end
X = "Elapsed " ..OOO1 .. hour .." " .. OOO2 .. min .. OOO3 .. sec
reaper.osara_outputMessage(X)
else
    local Q = reaper.format_timestr_pos(mono,'',1)
 OOO1, OOO2, OOO3 = SplitFilename(Q)

local pp = 1
                local name1 = string.match(string.reverse(OOO1),".+",pp+1)
                if not name1 then name1 = "" end
                local name1 = string.reverse(name1)
local ppp = 2

OOO11 = OOO1 -1
                local name11 = string.match(string.reverse(OOO11),".+",ppp+1)
                if not name11 then name11 = "" end
                local name11 = string.reverse(name11)
local pp = 1

                local name2 = string.match(string.reverse(OOO2),".+",pp+1)
                if not name2 then name1 = "" end
                local name2 = string.reverse(name2)


                local name3 = string.match(string.reverse(OOO3),".+",pp+1)
                if not name3 then name3 = "" end
                local name3 = string.reverse(name3)



if (tonumber(name11) == nil) then
 Bar = ""
elseif (tonumber(name11) == 0) then
Bar = ""
name1 = ""
name11 = ""
elseif (tonumber(name111) == 1) then
Bar = "Bar"
name1 = name11
 else
Bar = "Bars"
name1 = name11






 end
if (tonumber(OOO2) == nil) then
 min = ""
elseif (tonumber(name1) == nil) and (tonumber(OOO2) == 1) then
 min = ""
name2 = ""
elseif not (tonumber(name11) == 0) and (tonumber(OOO2) == 1) then
 min = "Beat"
 else
 min = "Beats"
 end


X = "Elapsed " ..name1 .. Bar .. name2 .. min.. name3 .."%" 
reaper.osara_outputMessage(X)




end

