]> git.wh0rd.org - tt-rss.git/commitdiff
remove js-based player, better mp3 support detection for html5 audio
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 16 Apr 2013 11:44:38 +0000 (15:44 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Tue, 16 Apr 2013 11:44:38 +0000 (15:44 +0400)
classes/rpc.php
include/functions.php
js/tt-rss.js
js/viewfeed.js

index 1569a9a35bc8fd4ea7b162056b45464307ba9c0f..b6d552868939a6ab736591d0eac69a4536638988 100644 (file)
@@ -334,6 +334,7 @@ class RPC extends Handler_Protected {
        function sanityCheck() {
                $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
                $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
+               $_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
 
                $reply = array();
 
index 018520648d1162f17bd7ff21905edd9320ae4c17..87eb3d6a9d7c585e8f586a473c10db8954b5b4bc 100644 (file)
                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 )) {
+                               $_SESSION["hasMp3"])) {
 
-                               $id = 'AUDIO-' . uniqid();
-
-                               $entry .= "<audio id=\"$id\"\" controls style='display : none'>
+                               $entry .= "<audio controls>
                                        <source type=\"$ctype\" 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\"
index a572e532411a3e643b740ded65fc7fb6500b0628..fe12297d4378021da117ea1c0de10ebf7ba9a3cd 100644 (file)
@@ -248,11 +248,15 @@ function init() {
 
                loading_set_progress(20);
 
-               var hasAudio = !!((myAudioTag = document.createElement('audio')).canPlayType);
+               var a = document.createElement('audio');
+
+               var hasAudio = !!a.canPlayType;
                var hasSandbox = "sandbox" in document.createElement("iframe");
+               var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
 
                new Ajax.Request("backend.php", {
                        parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
+                               hasMp3: hasMp3,
                                hasSandbox: hasSandbox},
                        onComplete: function(transport) {
                                        backend_sanity_check_callback(transport);
index 519ab3449336cbbe5fc5313a3e96ee11d73cb105..ddee1e461c666107f569e17dc2dfd394a8132263 100644 (file)
@@ -2027,34 +2027,6 @@ function initHeadlinesMenu() {
        }
 }
 
-
-function player(elem) {
-       var aid = elem.getAttribute("audio-id");
-       var status = elem.getAttribute("status");
-
-       var audio = $(aid);
-
-       if (audio) {
-               if (status == 0) {
-                       audio.play();
-                       status = 1;
-                       elem.innerHTML = __("Playing...");
-                       elem.title = __("Click to pause");
-                       elem.addClassName("playing");
-               } else {
-                       audio.pause();
-                       status = 0;
-                       elem.innerHTML = __("Play");
-                       elem.title = __("Click to play");
-                       elem.removeClassName("playing");
-               }
-
-               elem.setAttribute("status", status);
-       } else {
-               alert("Your browser doesn't seem to support HTML5 audio.");
-       }
-}
-
 function cache_set(id, obj) {
        //console.log("cache_set: " + id);
        if (has_storage)