1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 17:59:21 +02:00

Add Waveform feature and few ShoutBox links

This commit is contained in:
Afterster 2014-01-04 21:04:30 +01:00
parent 96736475cc
commit 0ec26ed623
16 changed files with 517 additions and 38 deletions

View file

@ -7,7 +7,7 @@
; if this config file is up to date
; this is compared against a value hard-coded
; into the init script
config_version = 12
config_version = 13
;###################
; Path Vars #
@ -192,23 +192,30 @@ require_localnet_session = "true"
; File Zip Download
; This settings tells Ampache to attempt to save the zip file
; to the filesystem instead of creating it in memory, you must
; also set file_zip_path in order for this to work
; also set tmp_dir_path in order for this to work
; DEFAULT: false
;file_zip_download = "false"
; File Zip Path
; If File Zip Download is enabled this must be set to tell
; Ampache which directory to save the file to. Do not put a
; trailing slash or this will not work.
; DEFAULT: false
;file_zip_path = "false"
; File Zip Comment
; This is an optional configuration option that adds a comment
; to your zip files, this only applies if you've got allow_zip_downloads
; DEFAULT: Ampache - Zip Batch Download
;file_zip_comment = "Ampache - Zip Batch Download"
; Waveform
; This settings tells Ampache to attempt to generate a waveform
; for each song. It requires transcode and encode_args_wav settings.
; You must also set tmp_dir_path in order for this to work
; DEFAULT: false
;waveform = "false"
; Temporary Directory Path
; If File Zip Download or Waveform is enabled this must be set to tell
; Ampache which directory to save the temporary file to. Do not put a
; trailing slash or this will not work.
; DEFAULT: false
;tmp_dir_path = "false"
; This setting throttles a persons downloading to the specified
; bytes per second. This is not a 100% guaranteed function, and
; you should really use a server based rate limiter if you want
@ -613,6 +620,7 @@ refresh_limit = "60"
;encode_args_mp3 = "-vn -b:a %SAMPLE%K -c:a libmp3lame -f mp3 pipe:1"
;encode_args_ogg = "-vn -b:a %SAMPLE%K -c:a libvorbis -f ogg pipe:1"
;encode_args_m4a = "-vn -b:a %SAMPLE%K -c:a libfdk_aac -f adts pipe:1"
;encode_args_wav = "-vn -b:a %SAMPLE%K -c:a pcm_s16le -f wav pipe:1"
;######################################################
; these options allow you to configure your rss-feed

View file

@ -65,14 +65,14 @@ function send_zip( $name, $song_files )
{
// Check if they want to save it to a file, if so then make sure they've
// got a defined path as well and that it's writable.
if (AmpConfig::get('file_zip_download') && AmpConfig::get('file_zip_path')) {
if (AmpConfig::get('file_zip_download') && AmpConfig::get('tmp_dir_path')) {
// Check writeable
if (!is_writable(AmpConfig::get('file_zip_path'))) {
if (!is_writable(AmpConfig::get('tmp_dir_path'))) {
$in_memory = '1';
debug_event('Error','File Zip Path:' . AmpConfig::get('file_zip_path') . ' is not writable','1');
debug_event('Error','File Zip Path:' . AmpConfig::get('tmp_dir_path') . ' is not writable','1');
} else {
$in_memory = '0';
$basedir = AmpConfig::get('file_zip_path');
$basedir = AmpConfig::get('tmp_dir_path');
}
} else {

View file

@ -44,10 +44,8 @@ class Shoutbox
*/
private function _get_info($shout_id)
{
$sticky_id = Dba::escape($shout_id);
$sql = "SELECT * FROM `user_shout` WHERE `id`='$shout_id'";
$db_results = Dba::read($sql);
$sql = "SELECT * FROM `user_shout` WHERE `id` = ?";
$db_results = Dba::read($sql, array($shout_id));
$data = Dba::fetch_assoc($db_results);
@ -169,16 +167,10 @@ class Shoutbox
*/
public static function create($data)
{
$user = Dba::escape($GLOBALS['user']->id);
$text = Dba::escape(strip_tags($data['comment']));
$date = time();
$sticky = isset($data['sticky']) ? 1 : 0;
$object_id = Dba::escape($data['object_id']);
$object_type = Dba::escape($data['object_type']);
$sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`) " .
"VALUES ('$user','$date','$text','$sticky','$object_id','$object_type')";
$db_results = Dba::write($sql);
$sql = "INSERT INTO `user_shout` (`user`,`date`,`text`,`sticky`,`object_id`,`object_type`, `data`) " .
"VALUES (? , ?, ?, ?, ?, ?, ?)";
$db_results = Dba::write($sql, array($GLOBALS['user']->id, time(), strip_tags($data['comment']), $sticky, $data['object_id'], $data['object_type'], $data['data']));
$insert_id = Dba::insert_id();
@ -230,4 +222,18 @@ class Shoutbox
} // delete
public static function get_shouts($object_type, $object_id)
{
$sql = "SELECT * FROM `user_shout` WHERE `object_type` = ? AND `object_id` = ?";
$db_results = Dba::read($sql, array($object_type, $object_id));
$results = array();
while ($row = Dba::fetch_assoc($db_results))
{
$results[] = $row;
}
return $results;
}
} // Shoutbox class

View file

@ -346,6 +346,9 @@ class Update
$update_string = '- Add check update automatically option.<br />';
$version[] = array('version' => '360032','description' => $update_string);
$update_string = '- Add song waveform as song data.<br />';
$version[] = array('version' => '360033','description' => $update_string);
return $version;
}
@ -1968,4 +1971,20 @@ class Update
return true;
}
/**
* update_360033
*
* Add song waveform as song data
*/
public static function update_360033()
{
$sql = "ALTER TABLE `song_data` ADD `waveform` MEDIUMBLOB NULL AFTER `language`";
Dba::write($sql);
$sql = "ALTER TABLE `user_shout` ADD `data` VARCHAR(256) NULL AFTER `object_type`";
Dba::write($sql);
return true;
}
}

View file

@ -0,0 +1,309 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2013 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* Waveform code generation license:
*
*
* Copyright (c) 2011, Andrew Freiday
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*
* https://github.com/afreiday/php-waveform-png
*
*/
class Waveform
{
public $id;
/**
* Constructor
*/
private function __construct()
{
// Static
return false;
} // Constructor
public static function get($song_id)
{
$song = new Song($song_id);
$waveform = null;
if ($song->id)
{
$song->format();
$waveform = $song->waveform;
if (!$waveform)
{
$catalog = Catalog::create_from_id($song->catalog);
if ($catalog->get_type() == 'local')
{
$transcode_to = 'wav';
$valid_types = $song->get_stream_types();
if ($song->type != $transcode_to)
{
$basedir = AmpConfig::get('tmp_dir_path');
if ($basedir)
{
if ($transcode_cfg != 'never' && in_array('transcode', $valid_types))
{
$tmpfile = tempnam($basedir, $transcode_to);
$tfp = fopen($tmpfile, 'wb');
if (!is_resource($tfp)) {
debug_event('waveform', "Failed to open " . $tmpfile, 3);
return null;
}
$transcoder = Stream::start_transcode($song, $transcode_to);
$fp = $transcoder['handle'];
if (!is_resource($fp)) {
debug_event('waveform', "Failed to open " . $song->file . " for waveform.", 3);
return null;
}
do {
$buf = fread($fp, 2048);
fwrite($tfp, $buf);
} while (!feof($fp));
fclose($fp);
fclose($tfp);
$waveform = self::create_waveform($tmpfile);
//$waveform = self::create_waveform("C:\\tmp\\test.wav");
@unlink($tmpfile);
}
else
{
debug_event('waveform', 'transcode setting to wav required for waveform.', '3');
}
}
else
{
debug_event('waveform', 'tmp_dir_path setting required for waveform.', '3');
}
}
// Already wav file, no transcode required
else
{
$waveform = self::create_waveform($song->file);
}
}
if($waveform)
{
self::save_to_db($song_id, $waveform);
}
}
}
return $waveform;
}
protected static function findValues($byte1, $byte2){
$byte1 = hexdec(bin2hex($byte1));
$byte2 = hexdec(bin2hex($byte2));
return ($byte1 + ($byte2*256));
}
/**
* Great function slightly modified as posted by Minux at
* http://forums.clantemplates.com/showthread.php?t=133805
*/
protected static function html2rgb($input) {
$input=($input[0]=="#")?substr($input, 1,6):substr($input, 0,6);
return array(
hexdec(substr($input, 0, 2)),
hexdec(substr($input, 2, 2)),
hexdec(substr($input, 4, 2))
);
}
protected static function create_waveform($filename)
{
$detail = 5;
$width = 400;
$height = 32;
$foreground = '#FF0000';
$background = '';
$draw_flat = true;
// generate foreground color
list($r, $g, $b) = self::html2rgb($foreground);
$handle = fopen($filename, "r");
// wav file header retrieval
$heading[] = fread($handle, 4);
$heading[] = bin2hex(fread($handle, 4));
$heading[] = fread($handle, 4);
$heading[] = fread($handle, 4);
$heading[] = bin2hex(fread($handle, 4));
$heading[] = bin2hex(fread($handle, 2));
$heading[] = bin2hex(fread($handle, 2));
$heading[] = bin2hex(fread($handle, 4));
$heading[] = bin2hex(fread($handle, 4));
$heading[] = bin2hex(fread($handle, 2));
$heading[] = bin2hex(fread($handle, 2));
$heading[] = fread($handle, 4);
$heading[] = bin2hex(fread($handle, 4));
// wav bitrate
$peek = hexdec(substr($heading[10], 0, 2));
$byte = $peek / 8;
// checking whether a mono or stereo wav
$channel = hexdec(substr($heading[6], 0, 2));
$ratio = ($channel == 2 ? 40 : 80);
// start putting together the initial canvas
// $data_size = (size_of_file - header_bytes_read) / skipped_bytes + 1
$data_size = floor((filesize($filename) - 44) / ($ratio + $byte) + 1);
$data_point = 0;
// create original image width based on amount of detail
// each waveform to be processed with be $height high, but will be condensed
// and resized later (if specified)
$img = imagecreatetruecolor($data_size / $detail, $height);
// fill background of image
if ($background == "") {
// transparent background specified
imagesavealpha($img, true);
$transparentColor = imagecolorallocatealpha($img, 0, 0, 0, 127);
imagefill($img, 0, 0, $transparentColor);
} else {
list($br, $bg, $bb) = self::html2rgb($background);
imagefilledrectangle($img, 0, 0, (int) ($data_size / $detail), $height, imagecolorallocate($img, $br, $bg, $bb));
}
while(!feof($handle) && $data_point < $data_size){
if ($data_point++ % $detail == 0) {
$bytes = array();
// get number of bytes depending on bitrate
for ($i = 0; $i < $byte; $i++)
$bytes[$i] = fgetc($handle);
switch($byte){
// get value for 8-bit wav
case 1:
$data = self::findValues($bytes[0], $bytes[1]);
break;
// get value for 16-bit wav
case 2:
if(ord($bytes[1]) & 128)
$temp = 0;
else
$temp = 128;
$temp = chr((ord($bytes[1]) & 127) + $temp);
$data = floor(self::findValues($bytes[0], $temp) / 256);
break;
}
// skip bytes for memory optimization
fseek($handle, $ratio, SEEK_CUR);
// draw this data point
// relative value based on height of image being generated
// data values can range between 0 and 255
$v = (int) ($data / 255 * $height);
// don't print flat values on the canvas if not necessary
if (!($v / $height == 0.5 && !$draw_flat))
// draw the line on the image using the $v value and centering it vertically on the canvas
imageline(
$img,
// x1
(int) ($data_point / $detail),
// y1: height of the image minus $v as a percentage of the height for the wave amplitude
$height - $v,
// x2
(int) ($data_point / $detail),
// y2: same as y1, but from the bottom of the image
$height - ($height - $v),
imagecolorallocate($img, $r, $g, $b)
);
} else {
// skip this one due to lack of detail
fseek($handle, $ratio + $byte, SEEK_CUR);
}
}
// close and cleanup
fclose($handle);
ob_start();
// want it resized?
if ($width) {
// resample the image to the proportions defined in the form
$rimg = imagecreatetruecolor($width, $height);
// save alpha from original image
imagesavealpha($rimg, true);
imagealphablending($rimg, false);
// copy to resized
imagecopyresampled($rimg, $img, 0, 0, 0, 0, $width, $height, imagesx($img), imagesy($img));
imagepng($rimg);
imagedestroy($rimg);
} else {
imagepng($img);
}
imagedestroy($img);
$imgdata = ob_get_contents();
ob_clean ();
return $imgdata;
}
protected static function save_to_db($song_id, $waveform)
{
$sql = "UPDATE `song_data` SET `waveform` = ? WHERE `song_id` = ?";
return Dba::write($sql, array($waveform, $song_id));
}
} // Waveform class

View file

@ -64,7 +64,7 @@ if (!empty($link)) {
/** This is the version.... fluf nothing more... **/
$results['version'] = '3.7-develop';
$results['int_config_version'] = '12';
$results['int_config_version'] = '13';
if (!empty($results['force_ssl'])) {
$http_type = 'https://';

View file

@ -54,8 +54,8 @@ switch ($_REQUEST['action']) {
$results[] = array(
'type' => T_('Artists'),
'link' => $artist->f_link,
'label' => $artist->f_name,
'value' => $artist->f_name,
'label' => $artist->name,
'value' => $artist->name,
'rels' => '',
);
}

View file

@ -51,6 +51,12 @@ switch ($_REQUEST['action']) {
break;
}
$object->format();
if (strtolower(get_class($object)) == 'song')
{
$data = $_REQUEST['offset'];
}
// Now go ahead and display the page where we let them add a comment etc
require_once AmpConfig::get('prefix') . '/templates/show_add_shout.inc.php';
break;

View file

@ -25,6 +25,9 @@
margin-right: auto;
width: 500px;
min-width: 500px;
}
div.jp-area-center {
margin-top: 20px;
}
@ -488,6 +491,33 @@ div.playing_lyrics a {
text-decoration: none;
}
div.playing_actions {
position: absolute;
top: 60px;
left: 80px;
font-size:0.5em;
}
div.waveform {
position: absolute;
top: 50px;
left: 40px;
height: 32px;
}
div.waveform a {
cursor: crosshair;
}
div.waveform-time {
position: absolute;
display: block;
height: 100%;
width: 0px;
border: 1px solid #ffcaca;
left: 0px;
}
div.jp-title,
div.jp-playlist {
top: 0px;

View file

@ -20,7 +20,14 @@
*
*/
?>
<?php UI::show_box_top(T_('Post to Shoutbox'), 'box box_add_shout'); ?>
<?php
$boxtitle = T_('Post to Shoutbox') . ' ' . T_('on') . ' ' . $object->f_title;
if ($data)
{
$boxtitle .= ' (' . $data . ')';
}
UI::show_box_top($boxtitle, 'box box_add_shout');
?>
<form method="post" enctype="multipart/form-data" action="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=add_shout">
<table class="tabledata" cellpadding="0" cellspacing="0">
<tr>
@ -31,7 +38,7 @@
</tr>
<?php if (Access::check('interface','50')) { ?>
<tr>
<td><input type="checkbox" name="sticky" /> <strong><?php echo T_('Make Sticky'); ?></strong></td>
<td><input type="checkbox" name="sticky" /> <strong><?php echo T_('Stick to homepage'); ?></strong></td>
</tr>
<?php } ?>
<tr>
@ -39,6 +46,7 @@
<?php echo Core::form_register('add_shout'); ?>
<input type="hidden" name="object_id" value="<?php echo $object->id; ?>" />
<input type="hidden" name="object_type" value="<?php echo strtolower(get_class($object)); ?>" />
<input type="hidden" name="data" value="<?php echo $data; ?>" />
<input type="submit" value="<?php echo T_('Create'); ?>" />
</td>
</tr>

View file

@ -56,12 +56,12 @@ if (Art::is_enabled()) {
<?php } ?>
<td class="cel_action">
<?php if (AmpConfig::get('sociable')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=show_add_shout&amp;type=album&amp;id=<?php echo $album->id; ?>">
<a href="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=show_add_shout&type=album&amp;id=<?php echo $album->id; ?>">
<?php echo UI::get_icon('comment', T_('Post Shout')); ?>
</a>
<?php } ?>
<?php if (Access::check_function('batch_download')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/batch.php?action=album&amp;id=<?php echo $album->id; ?>">
<a href="<?php echo AmpConfig::get('web_path'); ?>/batch.php?action=album&id=<?php echo $album->id; ?>">
<?php echo UI::get_icon('batch_download', T_('Batch Download')); ?>
</a>
<?php } ?>

View file

@ -34,7 +34,7 @@
<td><textarea rows="5" cols="70" name="comment"><?php echo $shout->text; ?></textarea></td>
</tr>
<tr>
<td><input type="checkbox" name="sticky" <?php if ($shout->sticky == "1") { echo "checked"; } ?>/> <strong><?php echo T_('Make Sticky'); ?></strong></td>
<td><input type="checkbox" name="sticky" <?php if ($shout->sticky == "1") { echo "checked"; } ?>/> <strong><?php echo T_('Stick to homepage'); ?></strong></td>
</tr>
<tr>
<td>

View file

@ -28,6 +28,7 @@ function NavigateTo(url)
?>
<script type="text/javascript">
var jplaylist = null;
var timeoffset = 0;
$(document).ready(function(){
@ -116,6 +117,13 @@ if (!$isVideo) {
echo "var titleobj = (albumids[index] != null) ? '<a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/albums.php?action=show&album=' + albumids[index] + '\');\">' + obj.title + '</a>' : obj.title;";
echo "var artistobj = '<a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/artists.php?action=show&artist=' + artistids[index] + '\');\">' + obj.artist + '</a>';";
echo "var lyricsobj = '<a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/song.php?action=show_lyrics&song_id=' + songids[index] + '\');\">" . T_('Show Lyrics') . "</a>';";
echo "var actionsobj = '|';";
if (AmpConfig::get('sociable')) {
echo "actionsobj += ' <a href=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=song&id=' + songids[index] + '\');\">" . UI::get_icon('comment', T_('Post Shout')) . "</a>';";
}
if (AmpConfig::get('sociable')) {
echo "waveformobj = '<a href=\"#\" title=\"" . T_('Post Shout') . "\" onClick=\"javascript:NavigateTo(\'" . AmpConfig::get('web_path') . "/shout.php?action=show_add_shout&type=song&id=' + songids[index] + '&offset=\' + clickTimeOffset(event));\"><div class=\"waveform-time\"></div><img src=\"" . AmpConfig::get('web_path') . "/waveform.php?song_id=' + songids[index] + '\"></a>';";
}
} else {
echo "var titleobj = obj.title;";
echo "var artistobj = obj.artist;";
@ -124,11 +132,21 @@ if (!$isVideo) {
$('.playing_title').html(titleobj);
$('.playing_artist').html(artistobj);
<?php
if ($iframed && AmpConfig::get('show_lyrics')) {
if ($iframed) {
?>
$('.playing_actions').html(actionsobj);
<?php
if (AmpConfig::get('show_lyrics')) {
?>
$('.playing_lyrics').html(lyricsobj);
<?php
}
if (AmpConfig::get('waveform')) {
?>
$('.waveform').html(waveformobj);
<?php
}
}
}
if (AmpConfig::get('song_page_title')) {
if ($iframed) {
@ -156,12 +174,29 @@ if ($isVideo) {
}
?>
$("#jquery_jplayer_1").bind($.jPlayer.event.timeupdate, function (event) {
if (event.jPlayer.status.duration > 0)
{
var leftpos = 400 * (event.jPlayer.status.currentTime / event.jPlayer.status.duration);
$(".waveform-time").css({left: leftpos});
}
});
$("#jquery_jplayer_1").bind($.jPlayer.event.volumechange, function(event) {
$.cookie('jp_volume', event.jPlayer.options.volume, { expires: 7, path: '/'});
});
<?php echo WebPlayer::add_media_js($playlist); ?>
});
function clickTimeOffset(e) {
var parrentOffset = $(".waveform").offset().left;
var offset = e.pageX - parrentOffset;
var duration = $("#jquery_jplayer_1").data("jPlayer").status.duration;
var time = duration * (offset / 400);
return time;
}
</script>
</head>
<body>
@ -182,12 +217,13 @@ if (!$isVideo) {
<div class="playing_artist"></div>
<div class="playing_title"></div>
<div class="playing_lyrics"></div>
<div class="playing_actions"></div>
</div>
<?php
} else {
$playerClass = "jp-video jp-video-270p";
} ?>
<div class="jp-area">
<div class="jp-area <?php if(!AmpConfig::get('waveform')) echo "jp-area-center"; ?>">
<div id="jp_container_1" class="<?php echo $playerClass; ?>">
<div class="jp-type-playlist">
<div id="jquery_jplayer_1" class="jp-jplayer"></div>
@ -262,6 +298,9 @@ if ($isVideo) {
<li><a href="javascript:;" class="jp-repeat" tabindex="1" title="repeat">repeat</a></li>
<li><a href="javascript:;" class="jp-repeat-off" tabindex="1" title="repeat off">repeat off</a></li>
</ul>
<?php if (AmpConfig::get('waveform')) { ?>
<div class="waveform"></div>
<?php } ?>
<?php } ?>
</div>
</div>

View file

@ -43,6 +43,15 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
</div>
</dd>
<?php } ?>
<?php if (AmpConfig::get('waveform')) { ?>
<?php $rowparity = UI::flip_class(); ?>
<dt class="<?php echo $rowparity; ?>"><?php echo T_('Waveform'); ?></dt>
<dd class="<?php echo $rowparity; ?>">
<div id="waveform_<?php echo $song->id; ?>">
<img src="<?php echo AmpConfig::get('web_path'); ?>/waveform.php?song_id=<?php echo $song->id; ?>" />
</div>
</dd>
<?php } ?>
<?php $rowparity = UI::flip_class(); ?>
<dt class="<?php echo $rowparity; ?>"><?php echo T_('Action'); ?></dt>
<dd class="<?php echo $rowparity; ?>">
@ -53,6 +62,11 @@ $button_flip_state_id = 'button_flip_state_' . $song->id;
<?php echo Ajax::button('?page=stream&action=directplay&playtype=song&song_id=' . $song->id . '&append=true','play_add', T_('Play add song'),'addplay_song_' . $song->id); ?>
<?php } ?>
<?php echo Ajax::button('?action=basket&type=song&id=' . $song->id,'add', T_('Add'),'add_song_' . $song->id); ?>
<?php if (AmpConfig::get('sociable')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=show_add_shout&type=song&id=<?php echo $song->id; ?>">
<?php echo UI::get_icon('comment', T_('Post Shout')); ?>
</a>
<?php } ?>
<?php if (Access::check_function('download')) { ?>
<a href="<?php echo Song::play_url($song->id); ?>"><?php echo UI::get_icon('link', T_('Link')); ?></a>
<a href="<?php echo AmpConfig::get('web_path'); ?>/stream.php?action=download&amp;song_id=<?php echo $song->id; ?>"><?php echo UI::get_icon('download', T_('Download')); ?></a>

View file

@ -46,12 +46,12 @@
<td class="cel_action">
<a href="<?php echo $song->link; ?>"><?php echo UI::get_icon('preferences', T_('Song Information')); ?></a>
<?php if (AmpConfig::get('sociable')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=show_add_shout&amp;type=song&amp;id=<?php echo $song->id; ?>">
<a href="<?php echo AmpConfig::get('web_path'); ?>/shout.php?action=show_add_shout&type=song&id=<?php echo $song->id; ?>">
<?php echo UI::get_icon('comment', T_('Post Shout')); ?>
</a>
<?php } ?>
<?php if (Access::check_function('download')) { ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/stream.php?action=download&amp;song_id=<?php echo $song->id; ?>"><?php echo UI::get_icon('download', T_('Download')); ?></a><?php } ?>
<a href="<?php echo AmpConfig::get('web_path'); ?>/stream.php?action=download&song_id=<?php echo $song->id; ?>"><?php echo UI::get_icon('download', T_('Download')); ?></a><?php } ?>
<?php if (Access::check('interface','75')) { ?>
<a id="<?php echo 'edit_song_'.$song->id ?>" onclick="showEditDialog('song_row', '<?php echo $song->id ?>', '<?php echo 'edit_song_'.$song->id ?>', '<?php echo T_('Song edit') ?>', '<?php echo $tags_list ?>', 'song_', 'refresh_song')">
<?php echo UI::get_icon('edit', T_('Edit')); ?>

40
waveform.php Normal file
View file

@ -0,0 +1,40 @@
<?php
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
* Copyright 2001 - 2013 Ampache.org
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License v2
* as published by the Free Software Foundation.
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
/**
* Album Art
* This pulls album art out of the file using the getid3 library
* and dumps it to the browser as an image mime type.
*
*/
require_once 'lib/init.php';
if (!AmpConfig::get('waveform')) exit();
$id = $_REQUEST['song_id'];
$waveform = Waveform::get($id);
if ($waveform)
{
header('Content-type: image/png');
echo $waveform;
}