* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ require_once(drupal_get_path('module', 'audiofield') .'/multimediafile.inc'); /** * Implementation of hook_help(). */ function tinyplayer_help($section) { switch ($section) { case 'admin/help#tinyplayer': // Return a line-break version of the module README return filter_filter('process', 2, NULL, @file_get_contents( dirname(__FILE__)."/README.txt") ); } } /** * Implementation of hook_field_formatter_info(). */ function tinyplayer_field_formatter_info() { $formatters = array(); if (file_exists(drupal_get_path('module', 'tinyplayer') .'/tinyplayer.swf')) { $formatters['tinyplayer'] = array( 'label' => t('Tiny Player'), 'field types' => array('file_audio', 'link'), ); } return $formatters; } /** * Implementation of hook_field_formatter(). */ function tinyplayer_field_formatter($field, $item, $formatter) { global $base_url; if ( !in_array($field['type'], array('file_audio','link')) || !isset($item['fid']) || empty($item['fid'])){ return ''; } $file = _field_file_load($item['fid']); $file_url = check_url($base_url .'/'. $file['filepath']); return tinyplayer_view($file_url); } /** * Simple function to view a URL in tinyplayer */ function tinyplayer_view($file_url){ global $base_url; $params = array('width' => 14, 'height' => 14, 'wmode'=>'transparent', 'allowScriptAccess'=>'sameDomain', 'menu'=>'false'); $vars = array('mp3' => $file_url); return theme("swfobject_api", check_url($base_url .'/'.drupal_get_path('module', 'tinyplayer') .'/tinyplayer.swf'), $params, $vars); }