2013-12-07 88 views
0

我正在嘗試製作音頻播放器擴展程序,並且選擇包裝WordPress音頻here 到目前爲止,我已經在所有基於Webkit的瀏覽器上工作,但不在Firefox上。我試圖把自動啓動,我可以聽到在Firefox中的音頻,它告訴我,Flash和JS代碼加載正常,但不顯示(見附圖)。Flash Player不會顯示在Firefox上但不會顯示在Chrome上

我已經嘗試了所有的選項在我的頭,沒有工作。這是我第一次延期,所以請原諒我明白的任何事情,並向我指出。

下面是圖像

Working in Chromium

Errornous picture

以下是完整的類代碼

<?php 
/** 
    * Extension to Play Music Files 
    * Copyright 2013 Hosanna Higher Technologies 
    * Written by Stefano Mtangoo 
    * Wraps Wordpress Media Player 
    * 
*/ 
class AudioPlayer extends CWidget 
{ 
    /** 
    * Audio Player JS File 
    * For internal uses only 
    */ 
    protected $playerjs; 

    /** 
    * Audio Player Flash File 
    * For internal uses only 
    */ 
    protected $playerswf;// holds player flashplayer 

    /** 
    * Player Width 
    * @var integer 
    */ 
    public $width = 290;// holds player width 
    //=====================Reserver for future=== 
    /** 
    * Player title 
    * @var string 
    */ 
    public $title = "";// holds player width 

    /** 
    * Player descritption 
    * @var string 
    */ 
    public $summary = "";// holds player width 

    /** 
    * Player Options 
    * To see more information about using aforementioned player for non-Wordpress project, 
    * please visit {@link http://wpaudioplayer.com/standalone} 
    * @var array 
    */ 
    public $options = array(); 

    /** 
    * Player HTML additional attributes 
    * @var array 
    */ 
    public $htmlOptions = array(); 

    /** 
    * Player files Passed 
    * @var array 
    */ 
    public $tracks = array(); 

    /* 
    public function renderContentBegin() 
    { 
     echo CHtml::openTag('div', $this->htmlContentOptions); 
     if (!empty($this->content)) 
      echo $this->content; 
    } 
    */ 
    //================================= 

    /* 
    * called when we use $this->beginWidget to insert a widget in a view 
    */ 
    public function init() 
    { 
     if($this->playerjs===null) 
     { 
      $file=dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'audio-player.js'; 
      $this->playerjs=Yii::app()->getAssetManager()->publish($file); 
     } 
     if($this->playerswf===null) 
     { 
      $file=dirname(__FILE__).DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'player.swf'; 
      $this->playerswf=Yii::app()->getAssetManager()->publish($file); 
     } 

     $this->registerClientScript(); 

     parent::init(); 
    } 

    /* 
    * is called when we call $this->endWidget 
    */ 
    public function run() 
    { 
     //put all tracks 
     $id = microtime(); 
     $id = str_replace(" ", "", $id); 
     $id = str_replace(".", "", $id); 

     $this->htmlOptions['id'] = 'audioplayer_'.$id;//replace ID 

     echo CHtml::openTag('div', $this->htmlOptions); 
     echo '<p> Your Browser does not support flash!</p>'; 
     echo CHtml::closeTag('div') . "\n"; 

     $files = implode(',', $this->tracks); 

     $tracktoAdd = "AudioPlayer.embed(\"audioplayer_{$id}\", {soundFile: \"{$files}\"}); "; 
     echo CHtml::script($tracktoAdd); 
     //Yii::app()->clientScript->registerScript("audioplayer_js_{$id}",$tracktoAdd/*, CClientScript::POS_BEGIN */); 

    } 

    protected function registerClientScript() 
    { 
     $options = ""; 
     foreach ($this->options as $field => $value) 
     { 
      if(!empty($options)) 
      { 
      $options = $options. ",".$field.':'.$value; 
      } 
      else 
      { 
      $options = $options.$field.':'.$value; 
      } 
     } 

     // publish CSS or JavaScript file here... 
     $cs=Yii::app()->clientScript; 
     //$cs->registerCssFile($cssFile); 
     $cs->registerScriptFile($this->playerjs); 

     $JscodeForPlayer = 
         " 
         AudioPlayer.setup(\"$this->playerswf\", { 
          {$options}, 
         });"; 

     if(!$cs->isScriptRegistered('audioplayer')) 
      $cs->registerScript('audioplayer', $JscodeForPlayer, CClientScript::POS_HEAD ); //Player JS 
    } 
} 

下面是在瀏覽器中 輸出FF

<object id="audioplayer_0590975001386453307" width="200" height="24" type="application/x-shockwave-flash" name="audioplayer_0590975001386453307" style="outline: none" data="/assets/b5645ee9/player.swf"> 
<param name="bgcolor" value="#FFFFFF"> 
<param name="wmode" value="transparent"> 
<param name="menu" value="false"> 
<param name="flashvars" value="autostart=no&animation=no&soundFile=/uploads/mp3/2013_12_07_18_15_16.mp3,/uploads/mp3/2013_12_07_18_15_16.mp3,/uploads/mp3/2013_12_07_18_15_16.mp3&playerID=audioplayer_0590975001386453307"> 
</object> 
<script type="text/javascript"> 
/*<![CDATA[*/ 
AudioPlayer.embed("audioplayer_0590975001386453307", {soundFile: "/uploads/mp3/2013_12_07_18_15_16.mp3,/uploads/mp3/2013_12_07_18_15_16.mp3,/uploads/mp3/2013_12_07_18_15_16.mp3"}); 
/*]]>*/ 
</script> 

<object type="application/x-shockwave-flash" name="audioplayer_0250541001386451633" style="outline: none" data="/assets/b5645ee9/player.swf" width="200" height="24" id="audioplayer_0250541001386451633"> 
<param name="bgcolor" value="#FFFFFF"> 
<param name="wmode" value="transparent"> 
<param name="menu" value="false"> 
<param name="flashvars" value="autostart=no&amp;animation=no&amp;soundFile=/uploads/mp3/2013_12_07_18_15_16.mp3&amp;playerID=audioplayer_0250541001386451633"> 
</object> 

<script type="text/javascript"> 
/*<![CDATA[*/ 
AudioPlayer.embed("audioplayer_0250541001386451633", {soundFile: "/uploads/mp3/2013_12_07_18_15_16.mp3"}); 
/*]]>*/ 
</script> 

回答

0

Firefox不會允許從本地主機加載閃存。 我不知道爲什麼它的政策,但這不是一個錯誤,但一個* 功能 *

相關問題