remove js-based player, better mp3 support detection for html5 audio

This commit is contained in:
Andrew Dolgov 2013-04-16 15:44:38 +04:00
parent 82d77f24a5
commit 40fe2d7382
4 changed files with 8 additions and 38 deletions

View File

@ -334,6 +334,7 @@ class RPC extends Handler_Protected {
function sanityCheck() { function sanityCheck() {
$_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true"; $_SESSION["hasAudio"] = $_REQUEST["hasAudio"] === "true";
$_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true"; $_SESSION["hasSandbox"] = $_REQUEST["hasSandbox"] === "true";
$_SESSION["hasMp3"] = $_REQUEST["hasMp3"] === "true";
$reply = array(); $reply = array();

View File

@ -2990,19 +2990,12 @@
if (strpos($ctype, "audio/") === 0) { if (strpos($ctype, "audio/") === 0) {
if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false || if ($_SESSION["hasAudio"] && (strpos($ctype, "ogg") !== false ||
strpos($_SERVER['HTTP_USER_AGENT'], "Chrome") !== false || $_SESSION["hasMp3"])) {
strpos($_SERVER['HTTP_USER_AGENT'], "Safari") !== false )) {
$id = 'AUDIO-' . uniqid(); $entry .= "<audio controls>
$entry .= "<audio id=\"$id\"\" controls style='display : none'>
<source type=\"$ctype\" src=\"$url\"></source> <source type=\"$ctype\" src=\"$url\"></source>
</audio>"; </audio>";
$entry .= "<span onclick=\"player(this)\"
title=\"".__("Click to play")."\" status=\"0\"
class=\"player\" audio-id=\"$id\">".__("Play")."</span>";
} else { } else {
$entry .= "<object type=\"application/x-shockwave-flash\" $entry .= "<object type=\"application/x-shockwave-flash\"

View File

@ -248,11 +248,15 @@ function init() {
loading_set_progress(20); 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 hasSandbox = "sandbox" in document.createElement("iframe");
var hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
new Ajax.Request("backend.php", { new Ajax.Request("backend.php", {
parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio, parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
hasMp3: hasMp3,
hasSandbox: hasSandbox}, hasSandbox: hasSandbox},
onComplete: function(transport) { onComplete: function(transport) {
backend_sanity_check_callback(transport); backend_sanity_check_callback(transport);

View 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) { function cache_set(id, obj) {
//console.log("cache_set: " + id); //console.log("cache_set: " + id);
if (has_storage) if (has_storage)