Flash Player Does not Show up on Firefox but not Chromium

好久不见. 提交于 2019-12-25 02:39:07

问题


Am trying to make audio Player extension and I choose to wrap Wordpress Audio found here So Far I have it working on all Webkit based browsers but not on firefox. I have tried to put auto start on and I can hear audio in firefox which tells me that flash and JS code loads fine but does not show up (see attached images).

I have tried all options in my head and did not work. This is my very first extension so forgive anything that is obvious and point out to me please.

Here are images

Here is the full class code

<?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
    }
}

Here are the output in browsers 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>

Chromium

<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>

回答1:


Firefox does not allow loading flash from the Localhost. I don't know why its their policy but that is not a bug but a *feature*



来源:https://stackoverflow.com/questions/20447297/flash-player-does-not-show-up-on-firefox-but-not-chromium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!