Search code examples
phpcodeigniterfacebox

mp3 file doesn't play in Facebox


I am using Facebox. I have to play mp3files in Facebox. I included facebox.js and facebox.css

My view code is:

<script  type="text/javascript">
    $(document).ready(function () {

        $('a[rel*=facebox]').facebox();
    }
</script>

$res= explode('/',$val['audio_file']);

<a href="<?=base_url().'uploads/'.$val['audio_file'];?>" rel="facebox"><?=$res['1'];?></a>

I have to play this mp3 file in Facebox. Is it possible?

I have linked the mp3 file in anchor tag, then can I play that file in a facebox. Now it plays in big screen.


Solution

  • Include it in view

    <script type="javascript">
    
            $('#play').live('click', function(e) {                                           
            e.preventDefault();
            link=this.href;  
            jQuery.facebox({ ajax: link });
            });
    
            </script>
    
    <a id="play" href="<?=site_url('admin/test/playmp3/'.$val['id']);?>"><?=$res['1'];?></a>
    

    Include it in controller

    function playmp3($id)
    {
    $this->data['mp3']  = $this->test_model->getmp3($id);
    $this->load->vars($this->data);
    echo $this->load->view( $this->config->item('APP_template_dir').'admin/playmp3_view');
    }
    

    Create a new page playmp3_view and include it

        <div style="">
        <object type="application/x-shockwave-flash" data="<?=base_url().$this->config->item('APP_assets_admin').'/'.$this->config->item('APP_js');?>/player_mp3.swf" width="200" height="20">
       <param name="movie" value="<?=base_url().$this->config->item('APP_assets_admin').'/'.$this->config->item('APP_js');?>/player_mp3.swf" />
       <param name="FlashVars" value="mp3=<?=base_url().'uploads/'.$mp3->audio_file?>" /></object>
        </div>