summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin/mime_audio.php84
-rw-r--r--plugins/mime.audio.php320
-rw-r--r--templates/admin_mime_audio.tpl108
-rw-r--r--templates/mime_audio_inline_inc.tpl7
-rw-r--r--templates/mime_audio_player_inc.tpl29
-rw-r--r--templates/mime_audio_view_inc.tpl78
6 files changed, 626 insertions, 0 deletions
diff --git a/admin/mime_audio.php b/admin/mime_audio.php
new file mode 100644
index 0000000..ab5be22
--- /dev/null
+++ b/admin/mime_audio.php
@@ -0,0 +1,84 @@
+<?php
+require_once( '../../bit_setup_inc.php' );
+include_once( KERNEL_PKG_PATH.'simple_form_functions_lib.php' );
+
+$gBitSystem->verifyPermission( 'p_admin' );
+
+if( function_exists( 'shell_exec' )) {
+ $gBitSmarty->assign( 'ffmpeg_path', shell_exec( 'which ffmpeg' ));
+ $gBitSmarty->assign( 'mplayer_path', shell_exec( 'which mplayer' ));
+ $gBitSmarty->assign( 'lame_path', shell_exec( 'which lame' ));
+}
+
+$feedback = array();
+
+$rates = array(
+ 'audio_bitrate' => array(
+ 32000 => 32,
+ 64000 => 64,
+ 96000 => 96,
+ 128000 => 128,
+ 160000 => 160,
+ 192000 => 192,
+ ),
+ 'audio_samplerate' => array(
+ 11025 => 11025,
+ 22050 => 22050,
+ 44100 => 44100,
+ ),
+);
+$gBitSmarty->assign( 'rates', $rates );
+
+if( !empty( $_REQUEST['plugin_settings'] )) {
+ $audioSettings = array(
+ 'mime_audio_ffmpeg_path' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_ffmpeg_use' => array(
+ 'type' => 'checkbox',
+ ),
+ 'mime_audio_samplerate' => array(
+ 'type' => 'numeric',
+ ),
+ 'mime_audio_bitrate' => array(
+ 'type' => 'numeric',
+ ),
+ 'mime_audio_mplayer_path' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_lame_path' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_lame_options' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_lame_options' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_backcolor' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_frontcolor' => array(
+ 'type' => 'text',
+ ),
+ 'mime_audio_force_encode' => array(
+ 'type' => 'checkbox',
+ ),
+ );
+
+ foreach( $audioSettings as $item => $data ) {
+ if( $data['type'] == 'checkbox' ) {
+ simple_set_toggle( $item, LIBERTY_PKG_NAME );
+ } elseif( $data['type'] == 'numeric' ) {
+ simple_set_int( $item, LIBERTY_PKG_NAME );
+ } else {
+ $gBitSystem->storeConfig( $item, ( !empty( $_REQUEST[$item] ) ? $_REQUEST[$item] : NULL ), LIBERTY_PKG_NAME );
+ }
+ }
+
+ $feedback['success'] = tra( 'The plugin was successfully updated' );
+}
+
+$gBitSmarty->assign( 'feedback', $feedback );
+$gBitSystem->display( 'bitpackage:liberty/admin_mime_audio.tpl', tra( 'Flashvideo Plugin Settings' ));
+?>
diff --git a/plugins/mime.audio.php b/plugins/mime.audio.php
new file mode 100644
index 0000000..c8be88b
--- /dev/null
+++ b/plugins/mime.audio.php
@@ -0,0 +1,320 @@
+<?php
+/**
+ * @version $Header: /cvsroot/bitweaver/_bit_liberty/plugins/mime.audio.php,v 1.1 2008/05/23 19:35:15 squareing Exp $
+ *
+ * @author xing <xing@synapse.plus.com>
+ * @version $Revision: 1.1 $
+ * created Thursday May 08, 2008
+ * @package liberty
+ * @subpackage liberty_mime_handler
+ **/
+
+/**
+ * setup
+ */
+global $gLibertySystem;
+
+/**
+ * This is the name of the plugin - max char length is 16
+ * As a naming convention, the treasury mime handler definition should start with:
+ * PLUGIN_MIME_GUID_
+ */
+define( 'PLUGIN_MIME_GUID_AUDIO', 'mimeaudio' );
+
+$pluginParams = array (
+ // Set of functions and what they are called in this paricular plugin
+ // Use the GUID as your namespace
+ 'verify_function' => 'mime_default_verify',
+ 'store_function' => 'mime_audio_store',
+ 'update_function' => 'mime_audio_update',
+ 'load_function' => 'mime_audio_load',
+ 'download_function' => 'mime_default_download',
+ 'expunge_function' => 'mime_default_expunge',
+ // Brief description of what the plugin does
+ 'title' => 'Extract Audio File Information',
+ 'description' => 'This plugin will extract as much information about an uploaded audio file as possible and allow you to listen to it on the website using a streaming player.',
+ // Templates to display the files
+ 'view_tpl' => 'bitpackage:liberty/mime_audio_view_inc.tpl',
+ 'inline_tpl' => 'bitpackage:liberty/mime_audio_inline_inc.tpl',
+ //'edit_tpl' => 'bitpackage:liberty/mime_audio_edit_inc.tpl',
+ // url to page with options for this plugin
+ 'plugin_settings_url' => LIBERTY_PKG_URL.'admin/mime_audio.php',
+ // This should be the same for all mime plugins
+ 'plugin_type' => MIME_PLUGIN,
+ // Set this to TRUE if you want the plugin active right after installation
+ 'auto_activate' => FALSE,
+ 'processing_options' => '',
+ // this should pick up all audio
+ 'mimetypes' => array(
+ '#audio/.*#i',
+ ),
+);
+$gLibertySystem->registerPlugin( PLUGIN_MIME_GUID_AUDIO, $pluginParams );
+
+// depending on the scan the default file might not be included yet. we need to get it manually - simply use the relative path
+require_once( 'mime.default.php' );
+require_once( UTIL_PKG_PATH.'getid3/getid3/getid3.php' );
+
+/**
+ * Store the data in the database
+ *
+ * @param array $pStoreRow File data needed to store details in the database - sanitised and generated in the verify function
+ * @access public
+ * @return TRUE on success, FALSE on failure - $pStoreRow['errors'] will contain reason
+ */
+function mime_audio_store( &$pStoreRow ) {
+ // this will set the correct pluign guid, even if we let default handle the store process
+ $pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_AUDIO;
+ $pStoreRow['log'] = array();
+
+ // if storing works, we process the audio
+ if( $ret = mime_default_store( $pStoreRow )) {
+ if( !mime_audio_converter( $pStoreRow )) {
+ // if it all goes tits up, we'll know why
+ $pStoreRow['errors'] = $pStoreRow['log'];
+ $ret = FALSE;
+ }
+ }
+ return $ret;
+}
+
+/**
+ * mime_audio_update
+ *
+ * @param array $pStoreRow
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function mime_audio_update( &$pStoreRow ) {
+ // this will set the correct pluign guid, even if we let default handle the store process
+ $pStoreRow['attachment_plugin_guid'] = PLUGIN_MIME_GUID_AUDIO;
+ $pStoreRow['log'] = array();
+
+ // if storing works, we process the audio
+ if( $ret = mime_default_update( $pStoreRow )) {
+ if( !mime_audio_converter( $pStoreRow )) {
+ // if it all goes tits up, we'll know why
+ $pStoreRow['errors'] = $pStoreRow['log'];
+ $ret = FALSE;
+ }
+ }
+ return $ret;
+}
+
+/**
+ * Load file data from the database
+ *
+ * @param array $pFileHash Contains all file information
+ * @param array $pPrefs Attachment preferences taken liberty_attachment_prefs
+ * @param array $pParams Parameters for loading the plugin - e.g.: might contain values from the view page
+ * @access public
+ * @return TRUE on success, FALSE on failure - ['errors'] will contain reason for failure
+ */
+function mime_audio_load( &$pFileHash, &$pPrefs, $pParams = NULL ) {
+ global $gLibertySystem, $gBitThemes;
+
+ // don't load a mime image if we don't have an image for this file
+ $pFileHash['no_mime_image'] = TRUE;
+ if( $ret = mime_default_load( $pFileHash, $pParams )) {
+ // fetch meta data from the db
+ $ret['meta'] = LibertyMime::getMetaData( $pFileHash['attachment_id'], "ID3" );
+
+ if( !empty( $ret['source_file'] ) && is_file( dirname( $ret['source_file'] ).'/bitverted.mp3' )) {
+ $ret['audio_url'] = dirname( $ret['source_url'] ).'/bitverted.mp3';
+ // we need some javascript for the flv player:
+ $gBitThemes->loadJavascript( UTIL_PKG_PATH."javascript/flv_player/swfobject.js", FALSE, 25 );
+ }
+ }
+ return $ret;
+}
+
+/**
+ * mime_audio_converter
+ *
+ * @param array $pParamHash
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function mime_audio_converter( &$pParamHash ) {
+ global $gBitSystem;
+
+ // audio conversion can take a while
+ ini_set( "max_execution_time", "1800" );
+
+ $ret = FALSE;
+ $log = array();
+
+ $source = BIT_ROOT_PATH.$pParamHash['upload']['dest_path'].$pParamHash['upload']['name'];
+ $dest_path = dirname( $source );
+ $dest_file = $dest_path.'/bitverted.mp3';
+
+ if( @BitBase::verifyId( $pParamHash['attachment_id'] )) {
+ if( !$gBitSystem->isFeatureActive( 'mime_audio_force_encode' ) && preg_match( "!.mp3$!i", $pParamHash['upload']['name'] )) {
+ // make a copy of the original
+ copy( $source, $dest_file );
+ $ret = TRUE;
+ } else {
+ // TODO: have a better mechanism of converting audio to mp3. ffmpeg works well as long as the source is 'perfect'
+ // there are many audiofiles that can't be read by ffmpeg but by other tools like flac, faac, oggenc
+ // mplayer is very good, but has a lot of dependencies and not many servers have it installed
+
+ if( !( $ret = mime_audio_conver_ffmpeg( $pParamHash, $source, $dest_file ))) {
+ // fall back to using slower mplayer / lame combo
+ $ret = mime_audio_conver_mplayer_lame( $pParamHash, $source, $dest_file );
+ }
+
+ // if the conversion was successful, we'll copy the tags to the new mp3 file and import data to meta tables
+ if( $ret == TRUE ) {
+ $log['success'] = 'SUCCESS: Converted to mp3 audio';
+
+ // now that we have a new mp3 file, we might as well copy the tags accross in case someone downloads it
+ $getID3 = new getID3;
+ // we silence this since this will spew lots of ugly errors when using UTF-8 and some odd character in the file ID
+ $meta = @$getID3->analyze( $source );
+ getid3_lib::CopyTagsToComments( $meta );
+
+ require_once( UTIL_PKG_PATH.'getid3/getid3/write.php' );
+ // Initialize getID3 tag-writing module
+ $tagwriter = new getid3_writetags;
+ $tagwriter->filename = $dest_file;
+ $tagwriter->tagformats = array( 'id3v1', 'id3v2.3' );
+
+ // set various options
+ $tagwriter->overwrite_tags = TRUE;
+ $tagwriter->tag_encoding = "UTF-8";
+
+ // store the tags
+ $tagwriter->tag_data = $meta['comments'];
+
+ // write tags
+ if( !$tagwriter->WriteTags() ) {
+ $log['tagging'] = "There was a proglem writing the tags to the mp3 file.".implode( "\n\n", $tagwriter->errors );
+ }
+
+ // getID3 returns everything in subarrays - we want to store everything in [0]
+ foreach( $meta['comments'] as $key => $comment ) {
+ $store[$key] = $comment[0];
+ }
+
+ if( !LibertyMime::storeMetaData( $pParamHash['attachment_id'], 'ID3', $store )) {
+ $log['store_meta'] = "There was a problem storing the meta data in the database";
+ }
+
+ // TODO: when tags package is enabled add an option to add tags
+ // recommended tags might be artist and album
+
+ // TODO: fetch album cover from amazon.com or musicbrainz.org
+ // fetch lyrics from lyricwiki.org
+
+ //$item->mLogs['audio_converter'] = "Audio file was successfully converted to MP3.";
+ }
+ }
+ }
+
+ // update log
+ $pParamHash['log'] = array_merge( $pParamHash['log'], $log );
+
+ return $ret;
+}
+
+/**
+ * mime_audio_conver_mplayer_lame will decode the audio to wav using mplayer and then encode to mp3 using lame
+ *
+ * @param array $pParamHash file information
+ * @param array $pSource source file
+ * @param array $pDest destination file
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function mime_audio_conver_mplayer_lame( &$pParamHash, $pSource, $pDest ) {
+ global $gBitSystem;
+ $ret = FALSE;
+ $log = array();
+
+ if( !empty( $pParamHash ) && !empty( $pSource ) && is_file( $pSource ) && !empty( $pDest )) {
+ $mplayer = trim( $gBitSystem->getConfig( 'mime_audio_mplayer_path', shell_exec( 'which mplayer' )));
+ $lame = trim( $gBitSystem->getConfig( 'mime_audio_lame_path', shell_exec( 'which lame' )));
+
+ // confirm that both applications are available
+ if( $mm = shell_exec( "$mplayer 2>&1" ) && $ll = shell_exec( "$lame 2>&1" )) {
+ // we will decode the audio file using mplayer and encode using lame
+ $mplayer_params = " -quiet -vo null -vc dummy -af volume=0,resample=44100:0:1 -ao pcm:waveheader:file='$pSource.wav' '$pSource' ";
+ $lame_params = $gBitSystem->getConfig( "mime_audio_lame_options", " -b ".( $gBitSystem->getConfig( 'mime_audio_bitrate', 64000 ) / 1000 ))." '$pSource.wav' '$pDest' ";
+ $command = "$mplayer $mplayer_params && $lame $lame_params";
+ $debug = shell_exec( "$command 2>&1" );
+
+ // remove the temporary wav file again
+ @unlink( "$pSource.wav" );
+
+ // make sure the conversion was successfull
+ if( is_file( $pDest ) && filesize( $pDest ) > 1 ) {
+ $ret = TRUE;
+ } else {
+ // remove unsuccessfully converted file
+ @unlink( $pDest );
+ $log['message'] = 'ERROR: The audio you uploaded could not be converted by mplayer and lame. DEBUG OUTPUT: '.nl2br( $debug );
+
+ // write error message to error file
+ $h = fopen( dirname( $pDest )."/error", 'w' );
+ fwrite( $h, "$command\n\n$mm\n\n$ll\n\n$debug" );
+ fclose( $h );
+ }
+ }
+ }
+
+ // update log
+ $pParamHash['log'] = array_merge( $pParamHash['log'], $log );
+
+ return $ret;
+}
+
+/**
+ * mime_audio_conver_ffmpeg
+ *
+ * @param array $pParamHash file information
+ * @param array $pSource source file
+ * @param array $pDest destination file
+ * @access public
+ * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure
+ */
+function mime_audio_conver_ffmpeg( &$pParamHash, $pSource, $pDest ) {
+ global $gBitSystem;
+ $ret = FALSE;
+ $log = array();
+
+ if( !empty( $pParamHash ) && !empty( $pSource ) && is_file( $pSource ) && !empty( $pDest )) {
+ // these are set in the liberty plugin admin screen
+ $ffmpeg = trim( $gBitSystem->getConfig( 'mime_audio_ffmpeg_path', shell_exec( 'which ffmpeg' )));
+
+ if( $ff = shell_exec( "$ffmpeg 2>&1" )) {
+ // set up parameters to convert audio
+ $params =
+ " -i '$pSource'".
+ " -acodec libmp3lame".
+ " -ab ".trim( $gBitSystem->getConfig( 'mime_audio_bitrate', 64000 ).'b' ).
+ " -ar ".trim( $gBitSystem->getConfig( 'mime_audio_samplerate', 22050 )).
+ " -y '$pDest'";
+ $debug = shell_exec( "$ffmpeg $params 2>&1" );
+
+ // make sure the conversion was successfull
+ if( is_file( $pDest ) && filesize( $pDest ) > 1 ) {
+ $ret = TRUE;
+ } else {
+ // remove unsuccessfully converted file
+ @unlink( $pDest );
+ $log['message'] = 'ERROR: The audio you uploaded could not be converted by ffmpeg. DEBUG OUTPUT: '.nl2br( $debug );
+
+ // write error message to error file
+ $h = fopen( dirname( $pDest )."/error", 'w' );
+ fwrite( $h, "$ffmpeg $params\n\n$ff\n\n$debug" );
+ fclose( $h );
+ }
+ }
+ }
+
+ // update log
+ $pParamHash['log'] = array_merge( $pParamHash['log'], $log );
+
+ return $ret;
+}
+?>
diff --git a/templates/admin_mime_audio.tpl b/templates/admin_mime_audio.tpl
new file mode 100644
index 0000000..0649a57
--- /dev/null
+++ b/templates/admin_mime_audio.tpl
@@ -0,0 +1,108 @@
+{strip}
+<div class="display liberty">
+ <div class="header">
+ <h1>{tr}Flashvideo Plugin Settings{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form legend="Flashvideo specific settings"}
+ <p class="formhelp">
+ You can find some information relating to this plugin on the <a class="external" href="http://www.bitweaver.org/wiki/TreasuryFlvPlugin">TreasuryFlvPlugin plugin page</a> at bitweaver.org.
+ </p>
+
+ {if !$gLibertySystem->isPluginActive( 'mimeaudio' )}
+ {formfeedback error="This plugins has not been enabled. All settings you change here will have no effect on uploaded videos unless you enable the plugin in the liberty plugins administration screen"}
+ {/if}
+
+ {formfeedback hash=$feedback}
+ <p class="formhelp">{tr}You can spcify the path to either ffmpeg or mplayer and lame. If you have all applications installed, we will first try to convert audio files using ffmpeg and if that didn't work, we'll use mplayer and lame.{/tr}</p>
+
+ <div class="row">
+ {formlabel label="Path to ffmpeg" for="mime_audio_ffmpeg_path"}
+ {forminput}
+ <input type='text' name="mime_audio_ffmpeg_path" id="mime_audio_ffmpeg_path" size="40" value="{$gBitSystem->getConfig('mime_audio_ffmpeg_path')|escape|default:$ffmpeg_path}" />
+ {formhelp note="If this path is not correct, please set the correct path to ffmpeg."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Path to mplayer" for="mime_audio_mplayer_path"}
+ {forminput}
+ <input type='text' name="mime_audio_mplayer_path" id="mime_audio_mplayer_path" size="40" value="{$gBitSystem->getConfig('mime_audio_mplayer_path')|escape|default:$mplayer_path}" />
+ {formhelp note="If this path is not correct, please set the correct path to mplayer."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Path to lame" for="mime_audio_lame_path"}
+ {forminput}
+ <input type='text' name="mime_audio_lame_path" id="mime_audio_lame_path" size="40" value="{$gBitSystem->getConfig('mime_audio_lame_path')|escape|default:$lame_path}" />
+ {formhelp note="If this path is not correct, please set the correct path to lame."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Lame options" for="mime_audio_lame_options"}
+ {forminput}
+ <input type='text' name="mime_audio_lame_options" id="mime_audio_lame_options" size="40" value="{$gBitSystem->getConfig('mime_audio_lame_options')|escape|default:$lame_options}" />
+ {formhelp note="If you know your way around lame, you can insert your own options here to override the default settings."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Audio sample rate" for="mime_audio_samplerate"}
+ {forminput}
+ {html_options
+ options=$rates.audio_samplerate
+ values=$rates.audio_samplerate
+ name=mime_audio_samplerate
+ id=mime_audio_samplerate
+ selected=$gBitSystem->getConfig('mime_audio_samplerate')|default:22050} Hz
+ {formhelp note="Set the audio sample rate. The higher the bitrate the higher the quality but also the larger the file."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Audio bitrate" for="mime_audio_bitrate"}
+ {forminput}
+ {html_options
+ options=$rates.audio_bitrate
+ values=$rates.audio_bitrate
+ name=mime_audio_bitrate
+ id=mime_audio_bitrate
+ selected=$gBitSystem->getConfig('mime_audio_bitrate')|default:96000} kbits/s
+ {formhelp note="Set the audio bitrate. The higher the bitrate the higher the quality but also the larger the file."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Force encode" for="mime_audio_force_encode"}
+ {forminput}
+ <input type='checkbox' name="mime_audio_force_encode" id="mime_audio_force_encode" value="y" {if $gBitSystem->isFeatureActive('mime_audio_force_encode')}checked="checked"{/if} />
+ {formhelp note="When mp3 files are uploaded they can be used directly for streaming. If you enable this, the uploaded mp3 will be re-encoded usually reducing filesize for streaming. The originally uploaded file will still be available for download."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Foreground Colour" for="mime_audio_frontcolor"}
+ {forminput}
+ <input type='text' name="mime_audio_frontcolor" id="mime_audio_frontcolor" size="10" value="{$gBitSystem->getConfig('mime_audio_frontcolor')|default:"FFFFFF"}" />
+ {formhelp note="Foreground colour of the progress bar."}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Background Colour" for="mime_audio_backcolor"}
+ {forminput}
+ <input type='text' name="mime_audio_backcolor" id="mime_audio_backcolor" size="10" value="{$gBitSystem->getConfig('mime_audio_backcolor')|default:"000000"}" />
+ {formhelp note="Background colour of the progress bar."}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="plugin_settings" value="{tr}Save Plugin Settings{/tr}" />
+ </div>
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .liberty -->
+{/strip}
diff --git a/templates/mime_audio_inline_inc.tpl b/templates/mime_audio_inline_inc.tpl
new file mode 100644
index 0000000..a866c7f
--- /dev/null
+++ b/templates/mime_audio_inline_inc.tpl
@@ -0,0 +1,7 @@
+{strip}
+{if $attachment.source_url}
+ <div class="row" style="text-align:center;">
+ {include file="bitpackage:liberty/mime_audio_player_inc.tpl"}
+ </div>
+{/if}
+{/strip}
diff --git a/templates/mime_audio_player_inc.tpl b/templates/mime_audio_player_inc.tpl
new file mode 100644
index 0000000..b1c6029
--- /dev/null
+++ b/templates/mime_audio_player_inc.tpl
@@ -0,0 +1,29 @@
+{strip}
+{if $attachment.audio_url}
+ {if $area eq "storage_thumbs"}
+ {assign var=width value=160}
+ {assign var=height value=140}
+ {else}
+ {assign var=width value=400}
+ {assign var=height value=320}
+ {/if}
+ <div id="audio_player_{$area}{$attachment.attachment_id}"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this video.</div>
+ <script type="text/javascript">/* <![CDATA[ */
+ {if $attachment.thumbnail_url.medium}
+ var so = new SWFObject('{$smarty.const.UTIL_PKG_URL}javascript/flv_player/mediaplayer.swf','mpl','{$width}','{$height}','7');
+ so.addVariable("image","{$attachment.thumbnail_url.medium}");
+ {else}
+ var so = new SWFObject('{$smarty.const.UTIL_PKG_URL}javascript/flv_player/mediaplayer.swf','mpl','{$width}','20','7');
+ {/if}
+ so.addVariable("file","{$attachment.audio_url}");
+ so.addVariable("frontcolor","0x{$gBitSystem->getConfig('mime_audio_frontcolor','FFFFFF')}");
+ so.addVariable("backcolor","0x{$gBitSystem->getConfig('mime_audio_backcolor','000000')}");
+ so.write('audio_player_{$area}{$attachment.attachment_id}');
+ /* ]]> */</script>
+{/if}
+
+{if $area eq "storage_thumbs"}
+ {if $attachment.meta.title}{$attachment.meta.title}<br />{/if}
+ <a href="{$attachment.display_url}">{tr}Full Details{/tr}</a>
+{/if}
+{/strip}
diff --git a/templates/mime_audio_view_inc.tpl b/templates/mime_audio_view_inc.tpl
new file mode 100644
index 0000000..549feab
--- /dev/null
+++ b/templates/mime_audio_view_inc.tpl
@@ -0,0 +1,78 @@
+{strip}
+{if $attachment.audio_url}
+ <div class="row" style="text-align:center;">
+ {include file="bitpackage:liberty/mime_audio_player_inc.tpl"}
+ </div>
+{/if}
+
+{if $attachment.meta.title}
+ <div class="row">
+ {formlabel label="Title" for=""}
+ {forminput}
+ {$attachment.meta.title}
+ {/forminput}
+ </div>
+{/if}
+
+{if $attachment.meta.album}
+ <div class="row">
+ {formlabel label="Album" for=""}
+ {forminput}
+ {$attachment.meta.album}
+ {/forminput}
+ </div>
+{/if}
+
+{if $attachment.meta.artist}
+ <div class="row">
+ {formlabel label="Artist" for=""}
+ {forminput}
+ {$attachment.meta.artist}
+ {/forminput}
+ </div>
+{/if}
+
+{if $attachment.meta.year}
+ <div class="row">
+ {formlabel label="Year" for=""}
+ {forminput}
+ {$attachment.meta.year}
+ {/forminput}
+ </div>
+{/if}
+
+{if $attachment.meta.playtime_string}
+ <div class="row">
+ {formlabel label="Duration" for=""}
+ {forminput}
+ {$attachment.meta.playtime_string}
+ {/forminput}
+ </div>
+{/if}
+
+{if $attachment.download_url}
+ <div class="row">
+ {formlabel label="Filename" for=""}
+ {forminput}
+ <a href="{$attachment.download_url}">{$attachment.filename|escape}</a>
+ &nbsp; <small>({$attachment.mime_type})</small>
+ {* TODO: get this to work if $gContent->hasEditPermission() && $attachment.flv_url}
+ {form ipackage=treasury ifile="plugins/form.flv.php"}
+ <input type="hidden" name="content_id" value="{$gContent->mContentId}" />
+ <input type="submit" name="remove_original" value="{tr}Remove Original{/tr}" />
+ {formhelp note="This will remove the original file from the server. The falsh video will remain and you can still view the video but you cannot download the original anymore."}
+ {/form}
+ {/if*}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Filesize" for=""}
+ {forminput}
+ {$attachment.file_size|display_bytes}
+ {/forminput}
+ </div>
+{/if}
+
+{attachhelp legend=1 hash=$attachment}
+{/strip}