- Add full video support:

- Add video player in track page,
  - Add video download in track page,
  - Now support mp4 and webm video format,
  - Fix video support in play page,
- Minor bug fixes.
This commit is contained in:
agibert 2016-05-05 16:17:29 +00:00
parent 852d9f37da
commit dd233b73c0

View File

@ -1,8 +1,8 @@
<?
// $RCSfile: lmbrowse.php,v $
// $Revision: 1.18 $
// $Revision: 1.19 $
// $Name: $
// $Date: 2015/12/16 23:24:12 $
// $Date: 2016/05/05 16:17:29 $
// $Author: agibert $
/*
@ -1392,7 +1392,7 @@ xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
if( "{$news_tab[$i]["name"]}" != "")
{
echo " <enclosure url=\"{$news_tab[$i]["aimg"]}\" length=\"".filesize(".{$news_tab[$i]["rimg"]}")."\" type=\"picture/png\" />
echo " <enclosure url=\"{$news_tab[$i]["aimg"]}\" length=\"".filesize("{$news_tab[$i]["rimg"]}")."\" type=\"picture/png\" />
<link>{$news_tab[$i]["alink"]}</link>
<description>{$news_tab[$i]["alink"]}</description>
";
@ -1874,6 +1874,15 @@ function lmb_track_info_get( $play_type, $play_id, $play_priority, $track_id)
$replace_tab = array( "/mp3-192/", ".mp3");
$track_info["url"] = "/".str_replace( $search_tab, $replace_tab, "${track_file}");
if( file_exists( "{$play_path}/.hide" ))
{
$track_info["hide"] = "y";
}
else
{
$track_info["hide"] = "n";
}
}
return( $track_info);
@ -2044,7 +2053,14 @@ function lmb_tracklist_microdata( $play_type, $play_id, $play_priority)
for( $i = 0; $i < $tracks_nb; $i++)
{
echo " <div itemprop=\"tracks\" itemscope=\"itemscope\" itemtype=\"http://schema.org/MusicRecording\">
<meta itemprop=\"name\" content=\"{$track_list_info[$i]["title"]} ({$track_list_info[$i]["mix"]})\"/>
<meta itemprop=\"name\" content=\"{$track_list_info[$i]["title"]}";
if( "{$track_list_info[$i]["mix"]}" != "")
{
echo " ({$track_list_info[$i]["mix"]})";
}
echo "\"/>
<meta itemprop=\"byArtist\" content=\"{$track_list_info[$i]["artist"]}\"/>
<meta itemprop=\"inAlbum\" content=\"{$track_list_info[$i]["album"]}\"/>
<meta itemprop=\"author\" content=\"{$track_list_info[$i]["composer"]}\"/>
@ -2294,7 +2310,7 @@ function lmb_coverlist( $play_type, $play_id, $play_priority, $skin_path)
/* Video File Tab Get */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $video_id, $mode)
function lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $video_id, $video_codec, $mode)
{
global $lmb_url_post;
@ -2302,7 +2318,7 @@ function lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $video_id
$play_path = lmb_play_path_get( $play_type, $play_id, $play_priority);
$video_path = "{$play_path}/videos";
$cmd = "ls {$video_path}/{$video_id}-*-*-*.avi | sed -e 's/.*{$play_id}-.*-//' -e 's/.avi$//' | sort -rn";
$cmd = "ls {$video_path}/{$video_id}* | sed -e 's/.*-//' -e 's/\..*$//' | grep -v icon | grep -v poster | sort -rnu";
exec( $cmd, $video_format_tab);
$file_tab = array();
@ -2310,7 +2326,8 @@ function lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $video_id
for( $i = 0; $i < count($video_format_tab); $i++)
{
$video_format = "{$video_format_tab[$i]}";
$file_url = "{$video_path}/{$video_id}-*-{$video_format}.avi";
$file_url = "{$video_path}/{$video_id}-{$video_format}.{$video_codec}";
if( count( glob( "{$file_url}")))
{
@ -2323,9 +2340,56 @@ function lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $video_id
}
else
{
$tab = glob( "{$file_url}");
$file_tab[$i]["url"] = "{$tab[0]}";
$file_tab[$i]["url"] = "{$file_url}";
$size_tab = lmb_size_convert( filesize( "{$file_tab[$i]["url"]}"));
}
$file_tab[$i]["format"] = "{$video_format}";
$file_tab[$i]["size"] = "{$size_tab["size"]}";
$file_tab[$i]["unit"] = "{$size_tab["unit"]}";
}
}
return( $file_tab);
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* Video File Tab Get */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_video_file_tab_get2( $play_type, $play_id, $play_priority, $video_id, $video_codec, $mode)
{
global $lmb_url_post;
$play_path = lmb_play_path_get( $play_type, $play_id, $play_priority);
$video_path = "{$play_path}/videos";
$cmd = "ls {$video_path}/{$video_id}* | sed -e 's/.*-//' | grep -v icon | grep -v poster | sort -rn";
exec( $cmd, $video_format_tab);
$file_tab = array();
for( $i = 0; $i < count($video_format_tab); $i++)
{
$video_format = "{$video_format_tab[$i]}";
$file_url = "{$video_path}/{$video_id}-{$video_format}";
if( count( glob( "{$file_url}")))
{
if( $mode == "MULTI")
{
$file_tab[$i]["url"] = "{$lmb_url_post}?page=download&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}&amp;dtype=video&amp;vformat={$video_format}";
$file_size = lmb_download_videos( $play_type, $play_id, $play_priority, $video_format, "SIZE");
$size_tab = lmb_size_convert( $file_size);
}
else
{
$file_tab[$i]["url"] = "{$file_url}";
$size_tab = lmb_size_convert( filesize( "{$file_tab[$i]["url"]}"));
}
@ -2352,10 +2416,10 @@ function lmb_videolist( $play_type, $play_id, $play_priority, $skin_path)
ob_start();
$cmd="ls {$video_path}/*-icon.png | sed -e 's/-icon.png$//' -e 's/.*\///'";
exec($cmd, $video_tab);
$cmd="ls {$video_path}/* | sed -e 's/.*\.//' | grep -v \"png\" | sort -ru";
exec($cmd, $codec_tab);
if( count($video_tab) == 0 || ( file_exists( "{$video_path}/.hide" ) && ! lmb_admin_is()))
if( count( $codec_tab) == 0 || ( file_exists( "{$video_path}/.hide" ) && ! lmb_admin_is()))
{
echo " <tr class=\"videos2\" style=\"height: 60px\"><td class=\"videos1\"></td><td class=\"videos2\">&nbsp;&nbsp;</td></tr>
<tr class=\"videos1\" style=\"height: 110px\"><td class=\"videos1\"><div class=\"sprite-unknown-cover-96\"></div></td><td class=\"videos2\">&nbsp;No video found...&nbsp;</td></tr>
@ -2364,44 +2428,67 @@ function lmb_videolist( $play_type, $play_id, $play_priority, $skin_path)
}
else
{
$height = max( 110, ( ( 220 - 30) / count($video_tab)));
$file_tab = lmb_video_file_tab_get( $play_type, $play_id, $play_priority, "*", "MULTI");
$entry_tag = "
<tr class=\"videos0\" style=\"height: 30px\">
<td class=\"videos2\" colspan=\"4\" style=\"text-align: left;\">&nbsp;&nbsp;All the Videos&nbsp;</td>
$codec_nb = count( $codec_tab);
$title_tag = " <td class=\"videos2\" rowspan=\"{$codec_nb}\" colspan=\"3\" style=\"text-align: left;\">&nbsp;&nbsp;All the Videos&nbsp;</td>
";
lmb_file_entry_print( $file_tab, "videos5", "videos6", $entry_tag, count( $file_tab));
$file_tab = array();
$max_file_nb = 0;
foreach( $codec_tab as $codec)
{
$file_tab[ $codec] = lmb_video_file_tab_get( $play_type, $play_id, $play_priority, "*", "{$codec}", "MULTI");
$max_file_nb = max( $max_file_nb, count( $file_tab[ $codec]));
}
foreach( $codec_tab as $codec)
{
$entry_tag = " <tr class=\"videos0\" style=\"height: 30px\">
${title_tag} <td class=\"videos4\">&nbsp;</td>
<td class=\"videos4\">&nbsp;{$codec}&nbsp;</td>
";
lmb_file_entry_print( $file_tab[ $codec], "videos5", "videos6", "{$entry_tag}", $max_file_nb);
$title_tag = "";
}
$cmd="ls {$video_path}/* | grep -v -- -icon | grep -v -- -poster | sed -e 's/-[0-9][0-9]*p//' -e 's/.*\///' | sort -u";
exec($cmd, $video_tab);
$height = max( 86, ( ( 220 - 30 * $codec_nb) / count($extra_tab)));
for( $i = 0; $i < count($video_tab); $i++)
{
$tab = explode( "-", $video_tab[$i]);
$tab = explode( ".", "{$video_tab[$i]}");
$video_id = "{$tab[0]}";
$video_codec = "{$tab[1]}";
$tab = explode( "-", "{$video_id}");
$video_subid = "{$tab[0]}";
$video_track = "{$tab[1]}";
$video_mix = "{$tab[2]}";
$video_track_name = ucwords( str_replace( "_", " ", "{$video_track}"));
$video_mix_name = ucwords( str_replace( "_", " ", "{$video_mix}"));
$video_file = "{$video_id}-{$video_track}-{$video_mix}";
/* Video Entry */
$file_tab = lmb_video_file_tab_get( $play_type, $play_id, $play_priority, $i+1, "MONO");
$file_tab = lmb_video_file_tab_get( $play_type, $play_id, $play_priority, "{$video_id}", "{$video_codec}", "MONO");
$css_row = $i % 2 + 1;
$entry_tag = " <tr class=\"videos{$css_row}\" style=\"height: {$height}px\">
<td class=\"videos1\"><a href=\"{$file_tab[0]["url"]}\"><img class=\"button-item\" src=\"{$video_path}/{$video_file}-icon.png\" alt=\"\"/></a></td>
<td class=\"videos2\">&nbsp;{$video_id}&nbsp;</td>
<td class=\"videos1\"><a href=\"{$file_tab[0]["url"]}\"><img class=\"button-item\" src=\"{$video_path}/{$video_id}-icon.png\" alt=\"\"/></a></td>
<td class=\"videos2\">&nbsp;{$video_subid}&nbsp;</td>
<td class=\"videos3\">&nbsp;{$video_track_name}&nbsp;</td>
<td class=\"videos4\">&nbsp;{$video_mix_name}&nbsp;</td>
<td class=\"videos4\">&nbsp;{$video_codec}&nbsp;</td>
";
lmb_file_entry_print( $file_tab, "videos5", "videos6", "{$entry_tag}", count( $file_tab));
lmb_file_entry_print( $file_tab, "videos5", "videos6", "{$entry_tag}", $max_file_nb);
}
}
@ -2439,8 +2526,8 @@ function lmb_extra_file_tab_get( $play_type, $play_id, $play_priority, $extra_id
if( "{$extra_format}" != "icon")
{
$file_url = "{$extra_path}/{$play_id}-{$extra_id}-{$extra_format}.png";
$file_tag = "{$file_tag}<td class=\"extras5\">";
// $file_tag = "{$file_tag}<td class=\"extras5\">";
// echo ("EI: {$extra_id} FMT: {$extra_format} FU: $file_url\n");
if( count( glob( "{$file_url}")))
{
if( $mode == "MULTI")
@ -2844,18 +2931,28 @@ function lmb_tracklist_body( $skin_path)
$track_mix = "{$track_info_list[$i]["mix"]}";
$track_length = "{$track_info_list[$i]["length"]}";
$track_album = "{$track_info_list[$i]["album"]}";
$track_hide = "{$track_info_list[$i]["hide"]}";
$play_url = "{$lmb_url_post}?page=play&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}";
$track_url = "{$lmb_url_post}?page=track&amp;type={$play_type}&amp;id={$play_id}&amp;priority={$play_priority}&amp;tid={$track_id}";
$path = lmb_playtype_path_get( $play_type);
if( ! file_exists( "{$path}/{$play_priority}-{$play_id}/.hide" ))
if( "{$track_hide}" == "y")
{
$hide_flag="*";
}
else
{
$hide_flag="";
}
if( ( "{$track_hide}" == "n") || lmb_admin_is())
{
echo " <tr class=\"tracks{$css_row}\" style=\"height: {$height}px;\">";
echo "<td class=\"tracks1\">&nbsp;{$row}&nbsp;</td><td class=\"tracks2\">&nbsp;<div class=\"link-item\"><a href=\"{$track_url}\">{$track_title}</a></div>&nbsp;</td><td class=\"tracks3\">&nbsp;<div class=\"link-item\"><a href=\"{$track_url}\">{$track_mix}</a></div>&nbsp;</td><td class=\"tracks3\">&nbsp;{$track_length}&nbsp;</td><td class=\"tracks3\">&nbsp;{$play_type_name}&nbsp;</td><td class=\"tracks3\">&nbsp;<div class=\"link-item\"><a href=\"{$play_url}\">{$track_album}</a></div>&nbsp;</td></tr>
echo "<td class=\"tracks1\">&nbsp;{$row}&nbsp;</td><td class=\"tracks2\">&nbsp;<div class=\"link-item\"><a href=\"{$track_url}\">{$track_title}{$hide_flag}</a></div>&nbsp;</td><td class=\"tracks3\">&nbsp;<div class=\"link-item\"><a href=\"{$track_url}\">{$track_mix}</a></div>&nbsp;</td><td class=\"tracks3\">&nbsp;{$track_length}&nbsp;</td><td class=\"tracks3\">&nbsp;{$play_type_name}&nbsp;</td><td class=\"tracks3\">&nbsp;<div class=\"link-item\"><a href=\"{$play_url}\">{$track_album}</a></div>&nbsp;</td></tr>
";
$row++;
}
@ -3124,7 +3221,8 @@ function lmb_jplayer_insert( $play_type, $play_id, $play_priority, $track_id, $t
<tbody>
<tr style=\"background-color:#222222; height: 75px;\">
<td style=\"vertical-align: middle; padding: 10px 0px 0px 0px;\">
<audio controls autoplay style=\"width: 90%; \">
<audio controls autoplay style=\"width: 90%;\">
<source src=\"http://{$lmb_url_pre}/{$track_file_ogg}\" type=\"audio/ogg\">
<source src=\"http://{$lmb_url_pre}/{$track_file_mp3}\" type=\"audio/mpeg\">
Your browser does not support the audio element.
@ -3290,7 +3388,7 @@ function lmb_track_intro( $play_type, $play_id, $play_priority, $track_id, $trac
<table class=\"list\" border=\"0\" cellpadding=\"0\" cellspacing=\"10\" style=\"\">
<tbody>
<tr class=\"info0\" style=\"height: 0px;\">
<td class=\"info0\">Informations</td>
<td class=\"info0\">Information</td>
</tr>
<tr>
<td>
@ -3373,6 +3471,137 @@ echo " </td>
/*--------------------------------------------------------------------------------------------------------------------*/
/* Track Video */
/*--------------------------------------------------------------------------------------------------------------------*/
function lmb_track_video( $play_type, $play_id, $play_priority, $track_id, $track_name, $track_mix, $skin_path)
{
global $lmb_cookie_tab;
global $lmb_url_pre;
$play_path = lmb_play_path_get( $play_type, $play_id, $play_priority);
$cover_path = "{$play_path}/covers/{$play_id}-cover";
$logo_path = "{$play_path}/logos/{$play_id}-logo";
$track_path = "{$play_path}/tracks";
$video_path = "{$play_path}/videos";
$video_res_cookie = "video_res";
$prefix_url = "{$lmb_url_post}?cookie_id={$video_res_cookie}&cookie_value=";
$query_string = preg_replace( "/cookie_id={$video_res_cookie}&cookie_value=[^&]*&/", "", "{$_SERVER['QUERY_STRING']}");
$video_res_1080p_url = htmlentities( "{$prefix_url}1080p&{$query_string}");
$video_res_720p_url = htmlentities( "{$prefix_url}720p&{$query_string}");
$video_res_360p_url = htmlentities( "{$prefix_url}360p&{$query_string}");
$video_res = $lmb_cookie_tab[$video_res_cookie];
$video_res_tab = array();
if( "{$video_res}" == "")
{
$video_res = "1080p";
}
switch("{$video_res}")
{
case "1080p":
{
$video_res_1080p_class = "link-item-disabled";
$video_res_720p_class = "link-item";
$video_res_360p_class = "link-item";
break;
}
case "720p":
{
$video_res_1080p_class = "link-item";
$video_res_720p_class = "link-item-disabled";
$video_res_360p_class = "link-item";
break;
}
case "360p":
{
$video_res_1080p_class = "link-item";
$video_res_720p_class = "link-item";
$video_res_360p_class = "link-item-disabled";
break;
}
}
if( "{$track_mix}" == "")
{
$video_file_base = "{$track_id}-{$track_name}";
}
else
{
$video_file_base = "{$track_id}-{$track_name}-{$track_mix}";
}
$video_file_ogv = "{$video_path}/{$video_file_base}-{$video_res}.ogv";
$video_file_webm = "{$video_path}/{$video_file_base}-{$video_res}.webm";
$video_file_mp4 = "{$video_path}/{$video_file_base}-{$video_res}.mp4";
$poster_file = "{$video_path}/{$video_file_base}-poster.png";
if( file_exists( "{$video_file_mp4}"))
{
echo " <tr>
";
ob_start();
echo " <tr class=\"videos2\" style=\"height: 5px;\">
<td></td>
<td></td>
<td></td>
</tr>
<tr class=\"videos2\">
<td class=\"videos5\" style=\"width: 5px;\"></td>
<td class=\"videos2\">
<video class=\"link-item-big\" style=\"width: 100%; padding: 0px;\" controls poster=\"http://{$lmb_url_pre}/$poster_file\">
<source src=\"http://{$lmb_url_pre}/{$video_file_mp4}\" type=\"video/mp4\">
<source src=\"http://{$lmb_url_pre}/{$video_file_webm}\" type=\"video/webm\">
<source src=\"http://{$lmb_url_pre}/{$video_file_ogv}\" type=\"video/ogg\">
Your browser does not support the video tag.
</video>
</td>
<td class=\"videos5\" style=\"width: 5px; \"></td>
</tr>
<tr style=\"background-color:#222222; height: 25px;\">
<td class=\"videos5\" style=\"width: 5px;\"></td>
<td style=\"horizontal-align: left; vertical-align: middle;\">
<div style=\"font-size: 12px;\"><a rel=\"nofollow\" class=\"{$video_res_1080p_class}\" href=\"{$video_res_1080p_url}\">1080p</a>&nbsp;<a rel=\"nofollow\" class=\"{$video_res_720p_class}\" href=\"{$video_res_720p_url}\">720p</a>&nbsp;<a rel=\"nofollow\" class=\"{$video_res_360p_class}\" href=\"{$video_res_360p_url}\">360p</a></div>
</td>
<td class=\"videos5\" style=\"width: 5px;\"></td>
</tr>
<tr>
<td class=\"videos5\" style=\"width: 5px; \"></td>
</tr>
<tr class=\"videos2\" style=\"height: 5px;\">
<td></td>
<td></td>
<td></td>
</tr>
";
$data = ob_get_contents();
ob_end_clean();
lmb_make_tab( "video", "videos", "r", "/{$logo_path}-1-128.png", $data, $skin_path);
echo " </tr>
<tr><td><br/><br/><br/><br/><br/></td></tr>
";
}
}
/*--------------------------------------------------------------------------------------------------------------------*/
/* Track Download */
/*--------------------------------------------------------------------------------------------------------------------*/
@ -3388,7 +3617,6 @@ function lmb_track_download( $play_type, $play_id, $play_priority, $track_id, $t
$file_tag = lmb_track_file_tag_get( $play_type, $play_id, $play_priority, $track_id);
echo " <tr><td><br/></td></tr>
<tr>
<td colspan=\"3\">
@ -3403,7 +3631,21 @@ function lmb_track_download( $play_type, $play_id, $play_priority, $track_id, $t
<td class=\"title_r\" colspan=\"5\">Download&nbsp;</td>
</tr>
<tr class=\"row3\">{$file_tag}</tr>
</tbody>
<tr class=\"row4\">";
$file_tab = lmb_video_file_tab_get( $play_type, $play_id, $play_priority, "{$track_id}-{$track_name}-{$track_mix}", "mp4", "MONO");
if( count( $file_tab) != 0 && ( ! file_exists( "{$video_path}/.hide" ) || lmb_admin_is()))
{
for( $i = 0; $i < count($file_tab); $i++)
{
$file_tab[$i]["format"] = "mp4 {$file_tab[$i]["format"]}";
}
lmb_file_entry_print( $file_tab, "tracks7", "tracks6", "{$entry_tag}", 4);
}
echo " </tbody>
</table>
<br/>
<table class=\"list\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
@ -3522,6 +3764,9 @@ function lmb_track_body( $play_type, $play_id, $play_priority, $track_id, $skin_
/* --- Introduction --- */
lmb_track_intro( $play_type, $play_id, $play_priority, $track_id, $track_name, $track_mix, $skin_path);
/* --- Introduction --- */
lmb_track_video( $play_type, $play_id, $play_priority, $track_id, $track_name, $track_mix, $skin_path);
/* --- Download --- */
lmb_track_download( $play_type, $play_id, $play_priority, $track_id, $track_name, $track_mix, $skin_path);
}
@ -3638,7 +3883,7 @@ function lmb_download_covers( $play_type, $play_id, $play_priority, $cover_forma
function lmb_download_videos( $play_type, $play_id, $play_priority, $video_format, $mode)
{
$play_dir = lmb_play_path_get( $play_type, $play_id, $play_priority);
$file_list = "videos/*-{$video_format}.avi";
$file_list = "videos/*-{$video_format}.mp4";
return( lmb_download_file( $play_dir, $file_list, $mode, "{$play_id}-{$video_format}"));
}