]> git.wh0rd.org - tt-rss.git/blobdiff - functions.php
use html5 audio player instead of flash when possible
[tt-rss.git] / functions.php
index 17581789211c663fa7b3fbfa44ced9250575c8f1..90e23d89780c9110cea7eb17f8f110209de3dcfe 100644 (file)
 
                $entry = "";
 
-               if ($ctype == "audio/mpeg") {  
-                     
-                       $entry .= "<object type=\"application/x-shockwave-flash\" 
-                               data=\"extras/button/musicplayer.swf?song_url=$url\" 
-                               width=\"17\" height=\"17\" style='float : left; margin-right : 5px;'> 
-                                       <param name=\"movie\" value=\"extras/button/musicplayer.swf?song_url=$url\" /> </object>";  
+               if (strpos($ctype, "audio/") === 0) {  
+
+                       if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false ||
+                               strpos($_SERVER['HTTP_USER_AGENT'], "Chrome") !== false ||  
+                               strpos($_SERVER['HTTP_USER_AGENT'], "Safari") !== false )) {
+
+                               $id = 'AUDIO-' . uniqid();
+
+                               $entry .= "<audio id=\"$id\"\">
+                                       <source src=\"$url\"></source>
+                                       </audio>";      
+
+                               $entry .= "<span onclick=\"player(this)\" 
+                                       title=\"".__("Click to play")."\" status=\"0\"
+                                       class=\"player\" audio-id=\"$id\">".__("Play")."</span>";
+
+                       } else {
+                    
+                               $entry .= "<object type=\"application/x-shockwave-flash\" 
+                                       data=\"extras/button/musicplayer.swf?song_url=$url\" 
+                                       width=\"17\" height=\"17\" style='float : left; margin-right : 5px;'> 
+                                       <param name=\"movie\" 
+                                               value=\"extras/button/musicplayer.swf?song_url=$url\" />
+                                       </object>";  
+                       }
                }
 
+               $filename = substr($url, strrpos($url, "/")+1);
+
+               $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
+                       $filename . " (" . $ctype . ")" . "</a>";
+
                return $entry;
        }
 
        
                                if (!$ctype) $ctype = __("unknown type");
        
-                               $filename = substr($url, strrpos($url, "/")+1);
+#                              $filename = substr($url, strrpos($url, "/")+1);
        
                                $entry = format_inline_player($link, $url, $ctype);
        
-                               $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
-                                       $filename . " (" . $ctype . ")" . "</a>";
+#                              $entry .= " <a target=\"_blank\" href=\"" . htmlspecialchars($url) . "\">" .
+#                                      $filename . " (" . $ctype . ")" . "</a>";
        
                                array_push($entries_html, $entry);