Plugin Directory

Changeset 961284


Ignore:
Timestamp:
08/06/2014 07:58:03 PM (12 years ago)
Author:
zubaka
Message:

Fix links/file name problem. Sometime flash player did not understand correctly file names to play.

Location:
zbplayer/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • zbplayer/trunk/readme.txt

    r958291 r961284  
    44Tags: mp3, flash player, audio, easy control, noJS, small mp3 player, embed, media player, music player, mp3 player, cyrillic mp3 player, facebook share, share mp3, m4a, m4b, mp4, m4a player, m4b player, mp4 player, wav, wav player
    55Requires at least: 3.5
    6 Tested up to: 3.9.1
    7 Stable tag: 2.1.7
     6Tested up to: 3.9.2
     7Stable tag: 2.1.8
    88License: Dual Licensed under the MIT and GPLv2 or later
    99
     
    5151
    5252== Changelog ==
     53
     54= 2.1.8 =
     55*    Fix links/file name problem. Sometime flash player did not understand correctly file names to play.
    5356
    5457= 2.1.7 =
  • zbplayer/trunk/zbPlayer.admin.php

    r958291 r961284  
    77 *
    88 *  zbPlayer.admin.php
    9  *  Release 2.1.7 July 2014
     9 *  Release 2.1.8 August 2014
    1010 */
    1111// connect wordpress color picker
    1212WP_Enqueue_Script('farbtastic');
    1313WP_Enqueue_Style('farbtastic');
    14 WP_Enqueue_Script('zbplayer-options', get_bloginfo('wpurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))) . '/js/zbPlayerColors.js');
     14WP_Enqueue_Script('zbplayer-options', get_bloginfo('wpurl').'/'.str_replace("\\", '/', substr(realpath(dirname(__FILE__)), strlen(ABSPATH))) . '/js/zbPlayerColors.js');
    1515?>
    1616<div class="wrap">
  • zbplayer/trunk/zbPlayer.php

    r958291 r961284  
    44Plugin URI: http://gilevich.com/portfolio/zbplayer
    55Description: Converts mp3 files links to a small flash player and a link to download file mp3 file. Also you can share your mp3 files with that plugin.
    6 Version: 2.1.7
     6Version: 2.1.8
    77Author: Vladimir Gilevich
    88Author URI: http://gilevich.com/
     
    1010*/
    1111
    12 define('ZBPLAYER_VERSION', "2.1.7");
     12define('ZBPLAYER_VERSION', "2.1.8");
    1313define('ZBPLAYER_DEFAULT_WIDTH', "500");
    1414define('ZBPLAYER_DEFAULT_INITIALVOLUME', "60");
     
    4242add_action('plugins_loaded', 'zbp_init');
    4343
    44 WP_Enqueue_Style('zbplayer-style', get_bloginfo('wpurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))) . '/css/zbPlayer.css');
    45 WP_Enqueue_Script('zbplayer-flash', get_bloginfo('wpurl').'/'.Str_Replace("\\", '/', SubStr(RealPath(DirName(__FILE__)), Strlen(ABSPATH))) . '/js/zbPlayerFlash.js');
     44WP_Enqueue_Style('zbplayer-style', get_bloginfo('wpurl').'/'.str_replace("\\", '/', substr(realpath(dirname(__FILE__)), strlen(ABSPATH))) . '/css/zbPlayer.css');
     45WP_Enqueue_Script('zbplayer-flash', get_bloginfo('wpurl').'/'.str_replace("\\", '/', substr(realpath(dirname(__FILE__)), strlen(ABSPATH))) . '/js/zbPlayerFlash.js');
    4646
    4747function zbp_init()
     
    8282}
    8383
    84 // Replace mp3 links in content with player
     84/**
     85 * Replace mp3 links in content with player
     86 *
     87 * @param string $content
     88 * @return string
     89 */
    8590function zbp_content($content)
    8691{
     
    98103                    preg_match_all( $patternTitle, $matches[0][$key], $matchesTitle );
    99104                    $titles[] = isset($matchesTitle[2][0]) ? $matchesTitle[2][0] : urlencode( str_replace('_', '', strip_tags($matches[0][$key])) );
    100                     $links[] = zbp_urlencode($link);
     105                    $links[] = $link;
    101106                }
    102107            }
     
    112117                    . ' flashvars="loop='.$loop.'&animation='.$animation.'&amp;playerID=zbPlayer&amp;initialvolume='.$initialvolume . zbp_get_color_srt()
    113118                    . $titles
    114                     . '&amp;soundFile='.implode(',',$links)
     119                    . '&amp;encode=yes&amp;soundFile='.zbp_encode_source(implode(',',$links))
    115120                    . '&amp;autostart='.$autostart.'" type="application/x-shockwave-flash" class="player" src="'.plugin_dir_url(__FILE__).'data/player.swf" id="zbPlayer"/></div>';
    116121                $content = str_replace(get_option('zbp_collect_field'), $player, $content);
     
    141146}
    142147
    143 // Main code - insert player into content
     148/**
     149 * Main code - insert player into content
     150 *
     151 * @param array $matches
     152 * @return string
     153 */
    144154function zbp_insert_player($matches)
    145155{
     
    180190        . '<embed width="'.$width.'" height="26" wmode="transparent" menu="false" quality="high"'
    181191        . ' flashvars="loop='.$loop.'&animation='.$animation.'&amp;playerID=zbPlayer&amp;initialvolume='.$initialvolume . zbp_get_color_srt()
    182         . $titles.'&amp;soundFile='.zbp_urlencode($link)
     192        . $titles.'&amp;encode=yes&amp;soundFile='.zbp_encode_source($link)
    183193        . '&amp;autostart='.$autostart.'" type="application/x-shockwave-flash" class="zbPlayerFlash" src="'.plugin_dir_url(__FILE__).'data/player.swf" id="zbPlayer"/>';
    184194    $ret .= '<audio class="zbPlayerNative" src="'.$link.'" controls preload="none"></audio>';
     
    187197}
    188198
    189 // own ulrencode method - need to convert to utf8 filename if it is not in utf8
     199/**
     200 * Encodes the given string for flash player
     201 *
     202 * @param string $string String to encode
     203 * @return the encoded string
     204 */
     205function zbp_encode_source($string)
     206{
     207    $source = utf8_decode($string);
     208    $ntexto = "";
     209    $codekey = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
     210    for ($i = 0; $i < strlen($string); $i++) {
     211                $ntexto .= substr("0000".base_convert(ord($string{$i}), 10, 2), -8);
     212    }
     213    $ntexto .= substr("00000", 0, 6-strlen($ntexto)%6);
     214    $string = "";
     215    for ($i = 0; $i < strlen($ntexto)-1; $i = $i + 6) {
     216                $string .= $codekey{intval(substr($ntexto, $i, 6), 2)};
     217    }
     218   
     219    return $string;
     220}
     221
     222/**
     223 * own ulrencode method - need to convert to utf8 filename if it is not in utf8
     224 *
     225 * @param string $link
     226 * @return stting
     227 */
    190228function zbp_urlencode($link)
    191229{
     
    200238}
    201239
    202 // pathinfo with UTF-8 encoded file names too. Special thanks Pietro Baricco
     240/**
     241 * pathinfo with UTF-8 encoded file names too. Special thanks Pietro Baricco
     242 *
     243 * @param string $filepath
     244 * @return array
     245 */
    203246function zbp_mb_pathinfo($filepath)
    204247{
    205     preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im',$filepath,$m);
    206     if($m[1]) $ret['dirname']=$m[1];
    207     if($m[2]) $ret['basename']=$m[2];
    208     if($m[5]) $ret['extension']=$m[5];
    209     if($m[3]) $ret['filename']=$m[3];
     248    preg_match('%^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^\.\\\\/]+?)|))[\\\\/\.]*$%im', $filepath, $m);
     249    if ($m[1]) $ret['dirname'] = $m[1];
     250    if ($m[2]) $ret['basename'] = $m[2];
     251    if ($m[5]) $ret['extension'] = $m[5];
     252    if ($m[3]) $ret['filename'] = $m[3];
    210253    return $ret;
    211254}
    212255
    213 // replace special symbols to do not destoy flash vars
     256/**
     257 * replace special symbols to do not destoy flash vars
     258 *
     259 * @param string $string
     260 * @return string
     261 */
    214262function zbp_flash_entities($string)
    215263{
    216     return str_replace(array("%", "&","'"),array("%25","%26","%27"),$string);
     264    return str_replace(array("%", "&","'"), array("%25","%26","%27"), $string);
    217265}
    218266
     
    222270}
    223271
    224 // Add the script
     272/**
     273 * Add the script
     274 */
    225275function zbp_add_pages()
    226276{
    227277    // Add a new submenu under options
    228     add_options_page('zbPlayer','zbPlayer','manage_options','zbplayer','zbp_manage_page');
    229 }
    230 
    231 // Management Page
     278    add_options_page('zbPlayer', 'zbPlayer', 'manage_options', 'zbplayer', 'zbp_manage_page');
     279}
     280
     281/**
     282 * Management Page
     283 */
    232284function zbp_manage_page()
    233285{
     
    236288
    237289
    238 // Setup Function
     290/**
     291 * Setup Function
     292 *
     293 * @param string $ZBPLAYER_VERSION
     294 */
    239295function zbp_setup($ZBPLAYER_VERSION)
    240296{
    241     update_option('zbp_version',$ZBPLAYER_VERSION);
    242 }
    243 
    244 // Loads language files according to locale (only does this once per request)
     297    update_option('zbp_version', $ZBPLAYER_VERSION);
     298}
     299
     300/**
     301 * Loads language files according to locale (only does this once per request)
     302 */
    245303function zbp_load_language_file()
    246304{
Note: See TracChangeset for help on using the changeset viewer.