![]() music |
![]() | OSdata.com |
start time
summary
Advancing on the simple player, we look at how to trim the beginnings and ends of music videos.
![]() music |
![]() | OSdata.com |
Advancing on the simple player, we look at how to trim the beginnings and ends of music videos.
Advancing on the simple player, we look at how to trim the beginnings and ends of music videos.
We use the same components as the simple player and it is an exercise for the programmer to add the new capability.
Many music videos on YouTube (including official videos) have silence at the beginning and/or end, and some have narrative or other non-music portions before and/or after the music.
In this lesson, we learn how to trim the videos to just the part we want to hear in our player.
When you view a YouTube video, there is a timer at the bottom of the screen (you may need to place the cursor over the bottom of the video to bring it into view).
Watch for how much time passes before the music starts.
Store this as your new $starttime.
Adjust the total $songlength to subtract the $starttime (so the video doesnt sit around silent that long at the end).
You can further trim the $songlength to subtract silence or toher non-musical parts at the end of the video.
Remember to set $starttime to 0 or empty string "" for any videos that you want to have start normally at the beginning. if you choose to use an empty string, that will match storing NULL in your SQL data base, while the zero will match storing an actual numeric zero in your SQL data base. The choice is yours. both methods work.
I use the double quotes "" for an empty string simply because at a glance two single quotes in a row (monospace) '' or (proportional) '' can look like one double quote. I do this to prevent confusion, because confusion leads to programming errors.
The music video Walk by the Foo Fighters is a good example, because it has acting portions both before and after the actual music portion.
case 2 :
$youtubecode = '4PkcfQtibmU';
$songlength = '262';
$starttime = '63';
$songtitle = 'Walk';
$songartist = 'the Foo Fighters';
$description = 'This was the 2011 Grammy rock song.';
break;
In all cases where there is a $starttime, you need to create the correct GET string to add to the embed code.
Use the following example if you chose to use empty string to indicate starting at the normal beginning of the music video.
if ($starttime != "")
$starttag = '&start='.$starttime;
else
$starttag = "";
Or use the following example if you chose to use numeric zero to indicate starting at the normal beginning of the music video.
Note that in the second example, you test $starttime for numeric zero, but set your $starttag to the empty string, because you will be inserting a string into the embed code.
if ($starttime != 0)
$starttag = '&start='.$starttime;
else
$starttag = "";
Now adjust your embed code to indicate the start time for the video (highlighted in red).
echo "<p align=\"center\"><object style=\"height: 390px; width: 640px\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$youtubecode.$starttag."?version=3&autoplay=1&rel=0&feature=player_embedded\"><param name=\"allowFullScreen\" value=\"true\"><param name=\"allowScriptAccess\" value=\"always\"><embed src=\"http://www.youtube.com/v/".$youtubecode .$starttag."?version=3&autoplay=1&rel=0&feature=player_embedded\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowScriptAccess=\"always\" width=\"640\" height=\"360\"></object>\n";
Once you have made these adjustments to your music video player, you will have improved the listening experience.
If you find this interesting and want to contact me, write to Milo, PO Box 5237, Balboa Island, California, 92662, USA.
return to table of contents
free downloadable college text book
| previous page | next page |
I do the news as an unpaid volunteer for KOCI 101.5 FM, Newport Beach/Costa Mesa (also available on the web)

This web site handcrafted on Macintosh
computers using Tom Benders Tex-Edit Plus
and served using FreeBSD
.
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.
Copyright © 2011, 2012 Milo
Created: February 14, 2012 (using code started in September 2011)
Last Updated: February 16, 2012
return to table of contents
free downloadable college text book
| previous page | next page |