
 if not string.match( m_simpleTV.Control.CurrentAdress, '%$sibirsvr' ) then return end

 if m_simpleTV.User.Sibir.ScanServer == '1' then
      if m_simpleTV.User.Sibir.SvrTable == nil then
          m_simpleTV.Control.Action =  'stop'
          m_simpleTV.Control.EventPlayingInterval=0
          m_simpleTV.Control.EventTimeOutInterval=0  
        return
      end
 end
 --m_simpleTV.OSD.ShowMessage("Sibir event - " .. m_simpleTV.Control.Reason,0xFF00)
 if m_simpleTV.Control.Reason=='Error' or m_simpleTV.Control.Reason=='Timeout' then

 if m_simpleTV.User.Sibir.ScanServer == '1' then
--remove not working server from table
     if m_simpleTV.User.Sibir.LastServer ~= nil then
       local srv = string.match(m_simpleTV.User.Sibir.LastServer,'http://(.-)/')
         for i, v in ipairs(m_simpleTV.User.Sibir.SvrTable) do
         if srv == v then
          table.remove(m_simpleTV.User.Sibir.SvrTable,i)
    --debug_in_file(i .. '  ' ..  v .. '   '  .. srv .. ' not work \n\n') 
          end
        end
     end
 end     

   dofile(m_simpleTV.MainScriptDir .. "user/tvplaylists/sibir/getserver.lua")   
   if m_simpleTV.User.Sibir.LastServer == nil then
         m_simpleTV.Control.Action =  'stop'
	 m_simpleTV.Control.EventPlayingInterval=0
         m_simpleTV.Control.EventTimeOutInterval=0  
	return
   end

   m_simpleTV.Control.Action =  'repeat'
 return
 end 

 if m_simpleTV.Control.Reason=='Playing' then
   m_simpleTV.User.Sibir.ShowMenu = 1
   m_simpleTV.Control.EventPlayingInterval=0
   m_simpleTV.Control.EventTimeOutInterval=0  
    if m_simpleTV.User.Sibir.ShowMenu == 1 then
       m_simpleTV.User.Sibir.MenuId = m_simpleTV.Interface.AddExtMenu('Refresh Sibir server','user\\tvplaylists\\sibir\\refreshsvr.lua',string.byte('M'),1)
       m_simpleTV.User.Sibir.AC = m_simpleTV.Interface.AddExtMenu('Active clients','user\\tvplaylists\\tvscr\\getactiveclients.lua',string.byte('A'),2)
     end 
end

 if m_simpleTV.Control.Reason=='Stopped' then
 m_simpleTV.User.Sibir.ShowMenu = 0
    if m_simpleTV.User.Sibir.MenuId ~= nil or m_simpleTV.User.Sibir.AC ~= nil then
       m_simpleTV.Interface.RemoveExtMenu(m_simpleTV.User.Sibir.MenuId)
       m_simpleTV.Interface.RemoveExtMenu(m_simpleTV.User.Sibir.AC)
    end
 end 
  
 --Error|EndReached|Stopped|Playing|Sleeping|addressready|Timeout
--m_simpleTV.Control.CurrentAdress       Address from database
--m_simpleTV.Control.RealAdress			 Real Address

--output
--m_simpleTV.Control.CurrentAdress      Address from database
--m_simpleTV.Control.Action              dodefault|repeat|stop