Recent Topics

[Widget] Share my widget :Simple Music Bar

Started by on Feb 27, 2013 – Contents updated: Feb 27, 2013

Feb 27, 2013 16:38    

There is no doubt, b2evolution is great and fantastic!Mainly because my BLOG used for students and based on entertainment more, so I wrote a music bar widget. It's advantage is simple and convenient, the drawback is obvious, when the user clicks on a link, it will interrupt the music player to re-start.Frankly this is not a good design, but with my current level of programming, there is no way to solve.Iframe Perhaps it can, but it will mostly change the template code.

If evoskin able to generate an IFrame framework to place the music player, the other link click of the page will not affect it,! For the users of the program, who should be the most convenient!

PHP

<?php
 
if( !defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
 
load_class'widgets/model/_widget.class.php''ComponentWidget' );
 
/**
 * MusicWidget Class
 *
 * Simple show music bar 
 *
 * @package evocore
 */
class music_simple_Widget extends ComponentWidget
{
    /**
     * Constructor
     */
    function music_simple_Widget$db_row NULL )
    {
        // Call parent constructor:
        parent::ComponentWidget$db_row'core''music_simple' );
    }
 
 
    /**
     * Get name of widget
     */
    function get_name()
    {
        $title T_'Simple Music' );
        return $title;
    }
 
 
    /**
     * Get a very short desc. Used in the widget list.
     *
     * @return string The block title, the first 60 characters of the block
     *                content or an empty string.
     */
    function get_short_desc()
    {
        
        return T_("Music bar shown");
    }
 
 
  /**
     * Get short description
     */
    function get_desc()
    {
        return T_('Simple music bar shown on the blog!');
    }
 
 
  /**
   * Get definitions for editable params
   *
     * @see Plugin::GetDefaultSettings()
     * @param local params like 'for_editing' => true
     */
    function get_param_definitions$params )
    {
        // Demo data:
        $r array_mergearray(
                'title' => array(
                    'label' => T_('Block title'),
                    'size' => 60,
                ),
                'position_type' => array(
                    'label' => T_('Player position'),
                    'note' => T_('Css position type'),
                    'type' => 'radio',
                    'options' => arrayarray'static'T_('Static') ),
                                        array'absolute'T_('Absolute') ),
                                        array'fixed'T_('Fixed') ),
                                        array'relative'T_('Relative') )),
                    'defaultvalue' => 'static',
                ),
                'position_left' => array(
                    'label' => T_('Position left'),
                    'size' => 5,
                    'defaultvalue' => '10px',
                ),
                'position_top' => array(
                    'label' => T_('Position top'),
                    'size' => 5,
                    'defaultvalue' => '10px',
                ),
                'position_right' => array(
                    'label' => T_('Position right'),
                    'size' => 5,
                ),
                'position_bottom' => array(
                    'label' => T_('Position bottom'),
                    'size' => 5,
                ),
                'player_width' => array(
                    'label' => T_('Player bar width'),
                    'size' => 10,
                    'defaultvalue' => '200',
                ),
                'player_height' => array(
                    'label' => T_('Player bar height'),
                    'size' => 10,
                    'defaultvalue' => '10',
                ),
                'address_list' => array(
                    'type' => 'html_textarea',
                    'label' => T_('Songs address list'),
                    'note' => T_('Format:<br>song address|song title<br>Ex:<br>http://www.songtaste.com/a.mp3|title a<br>http://www.bb.com/b.mp3|title b'),
                    'rows' => '10',
                    'cols' => '100',
                ),
                
                'if_random' => array(
                    'label' => T_('Random play List'),
                    'note' => T_('Random the songs list to play'),
                    'type' => 'radio',
                    'options' => arrayarray'yes'T_('Yes') ),
                                        array'no'T_('No') ) ),
                    'defaultvalue' => 'no',
                ),
                'autoplay' => array(
                    'label' => T_('Autoplay'),
                    'note' => T_('Autoplay the songs list'),
                    'type' => 'radio',
                    'options' => arrayarray'true'T_('Yes') ),
                                        array'false'T_('No') ) ),
                    'defaultvalue' => 'true',
                ),
            ), parent::get_param_definitions$params )    );
 
        return $r;
 
    }
 
 
    /**
     * Display the widget!
     *
     * @param array MUST contain at least the basic display params
     */
    function display$params )
    {
        global $Blog;
 
        $this->init_display$params );
 
        // Collection common links:
        //echo $this->disp_params['block_start'];
 
        $this->disp_title$this->disp_params['title'] );
 
        //echo format_to_output( $this->disp_params['content'] );
        
        $player_url $Blog->get_local_media_url()."music/billy.swf";
 
 
        $address_list $this->disp_params['address_list'];
        if(trim($address_list)!="" && $address_list!=NULL){
            $temp_array explode('<br>',ereg_replace("\r\n","<br>",$address_list));
            $array_musics array_filter($temp_array);
            $count_musics count($array_musics);
            if($this->disp_params['if_random']=="yes"){
                shuffle($array_musics);
            }
            $i 0;
            $urlparams "";
            foreach ($array_musics as $key => $value) { 
                if(trim($value)!=""){
                    $temp_array explode("|",$value);
                    if($temp_array){
                        if(trim($temp_array[0])!=""){
                            $urlparams .= "&f".$i."=".urlencode($temp_array[0]);
                            if(count($temp_array)>=2){
                                $urlparams .= "&t".$i."=".$temp_array[1];
                            }else{
                                $urlparams .= "&t".$i."=".T_('No Title');
                            }
                            $i++;
                        }
                    }
                }
            }
            if($urlparams!=""){
                $urlparams .= "&total=".$count_musics;
                
            }
            $cssposition "position:".$this->disp_params['position_type'].";";
            if($this->disp_params['position_left']){
                $cssposition .= "left:".$this->disp_params['position_left'].";";
            }
            if($this->disp_params['position_top']){
                $cssposition .= "top:".$this->disp_params['position_top'].";";
            }
            if($this->disp_params['position_right']){
                $cssposition .= "right:".$this->disp_params['position_right'].";";
            }
            if($this->disp_params['position_bottom']){
                $cssposition .= "bottom:".$this->disp_params['position_bottom'].";";
            }
             
            echo '<div style="'.$cssposition.'"><embed src="'.$player_url.'?autoplay='.$this->disp_params['autoplay'].$urlparams.'" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" /></div>';
        }
        
 
        //echo $this->disp_params['block_end'];
 
        return true;
    }
}
 
 
/*
 * $Log: _free_html.widget.php,v $
 */
?>

Feb 27, 2013 16:47

Please unzip the attach file and put the billy.swf to rootdir/media/music/billy.swf


Attachments:


Form is loading...

b2 – This forum is powered by b2evolution CMS, a complete engine for your website.