=begin AUTHOR: Kesiev WHAT IT DOES: Hides the music shares that aren't reachable and show them when are online. It works polling the shares and changing their :hidden attribute. Suggestive iTunes effect with low effort :) =end Thread.new { # forever... while (1) do changed=false # Fetch all playlists... $lists.each_index { |i| # searches for http: shares if $lists[i][:file].to_s[0..4]=="http:" then ok=false; # Try to connect to the share. Timeout is 5 seconds. begin Timeout::timeout(5) { open($lists[i][:file],"r") { |f| } ok=true } rescue =>error end # If visibility state have to change, change it and remember that # the modes list have to be refreshed if ($lists[i][:hidden] ? $lists[i][:hidden] : false)==ok then $lists[i][:hidden]=!ok changed=true end end } # Update the modes list if needed updatemodes if changed # Wait for the next poll sleep 5 end }