From 7914b302330a4dc46631cbc5aace40395767ba5e Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 16 Mar 2012 18:03:35 -0400 Subject: [PATCH] CC-3429: Firefox does not natively support mp3 file playing so preview does nothing. - after reading about the trick foudn in Mark Panaghiston's posting from this link https://groups.google.com/forum/#!topic/jplayer/gTJrSCjwftw - the current imperfect solution for firefox sould be to show a video jplayer that can play all the audio types. --- .../application/controllers/ApiController.php | 7 +++++-- airtime_mvc/public/js/jplayer/preview_jplayer.js | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index d32f2ad30..5a0d53cd9 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -150,8 +150,11 @@ class ApiController extends Zend_Controller_Action //user clicks play button for track and downloads it. header('Content-Disposition: inline; filename="'.$file_base_name.'"'); } - - $this->smartReadFile($filepath, 'audio/'.$ext); + if ($ext === 'mp3'){ + $this->smartReadFile($filepath, 'audio/mpeg'); + } else { + $this->smartReadFile($filepath, 'audio/'.$ext); + } exit; }else{ header ("HTTP/1.1 404 Not Found"); diff --git a/airtime_mvc/public/js/jplayer/preview_jplayer.js b/airtime_mvc/public/js/jplayer/preview_jplayer.js index 2f6c2bd6f..e954a74b5 100644 --- a/airtime_mvc/public/js/jplayer/preview_jplayer.js +++ b/airtime_mvc/public/js/jplayer/preview_jplayer.js @@ -8,16 +8,22 @@ var _idToPostionLookUp; */ $(document).ready(function(){ + if (useFlash()) + mySupplied = "oga, mp3, m4v"; + else + mySupplied = "oga, mp3"; + _playlist_jplayer = new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" },[], //array of songs will be filled with below's json call { swfPath: "/js/jplayer", - //supplied: "mp3,oga", + supplied:mySupplied, wmode: "window" }); + $.jPlayer.timeFormat.showHour = true; var audioFileID = $('.audioFileID').text(); @@ -35,6 +41,10 @@ $(document).ready(function(){ } }); +function useFlash() { + console.log(navigator.userAgent); + return navigator.userAgent.toLowerCase().match('firefox'); +} /** * Sets up the jPlayerPlaylist to play. * - Get the playlist info based on the playlistID give. @@ -122,7 +132,7 @@ function play(p_playlistIndex){ function playOne(p_audioFileID) { var playlist = new Array(); var fileExtensioin = p_audioFileID.split('.').pop(); - + console.log(p_audioFileID); if (fileExtensioin === 'mp3') { media = {title: $('.audioFileTitle').text() !== 'null' ?$('.audioFileTitle').text():"", artist: $('.audioFileArtist').text() !== 'null' ?$('.audioFileArtist').text():"", @@ -135,7 +145,7 @@ function playOne(p_audioFileID) { }; } _playlist_jplayer.option("autoPlay", true); - + console.log(media); playlist[0] = media; //_playlist_jplayer.setPlaylist(playlist); --if I use this the player will call _init on the setPlaylist and on the ready _playlist_jplayer._initPlaylist(playlist);