Jump to content
TNG Community

Youtube Videos


Allen Prunty

Recommended Posts

Hi Allen,

I recently posted a mod which natively supports flash video (flv) in TNG and figured it would be easy to add a few more lines to support embedded videos such as youtube videos. (The original forum entry is here).

I don't necessarily think it is a great idea to make your family history site content depend on a 3rd party site like youtube as you are not in control of when the video might be removed (as you know, an embedded video does not actually physically reside on your site). The better alternative would be to download the file and upload it to your own site as a flv file or similar.

But anyway, there might be times when an embedded video could be appropriate, so what the heck, here is how to implement the mod (this version of the mode supports both flash video and embedded media):

1) Modify tngfiletypes.php adding the filetypes "FLV" and "EMB" to tngfiletypes.php in the videotypes array:

$videotypes = array( "AVI", "MPG", "MOV", "WMV", "3GP", "M4V", "MP4", "ASF", "FLV", "EMB" );
2) Make a backup copy of showmedialib.php 3) Modify the line after
function showMediaSource($imgrow) {
(at or around line 311) adding "$rootpath," as follows:
global $rootpath, $text, $usefolder, $size, …
4) Delete or comment out this line in showmedialib.php:
echo "<embed src=\"$mediasrc\"$widthstr$heightstr>\n";
(It will be at or around line 365) 5) Paste the following code in it's place:
//********************************* FLV and Embedded Video Mod by dlassen STARTS HERE *********************************
//comment out this line:
//echo "<embed src=\"$mediasrc\"$widthstr$heightstr>\n";
// and replace with:
      if ($imgrow[form] == 'FLV') {
       //this section is for flv video
         if ($imgrow[height]==0) {$flvheight = 300;}else{$flvheight = $imgrow[height];}
         if ($imgrow[width]==0) {$flvwidth = 400;}else{$flvwidth = $imgrow[width];}
         $preview_img = str_replace('.flv','.jpg',$mediasrc);
         echo "<script type='text/javascript' src='flvsupport/flowplayer-3.1.4.min.js'></script>";
         echo "<a href='$mediasrc'";
         echo "style='display:block;width:" . $flvwidth . "px; height:" . $flvheight . "px;' id='videoplayer'>";
         if (file_exists(str_replace('%20',' ',$preview_img))) {
            echo "<img src='$preview_img' style='display:block;width:" . $flvwidth . "px; height:" . $flvheight . "px' alt='Click here to play this video...' />";
         }elseif (file_exists("flvsupport/flvicon.png")) {
            echo "<img src='flvsupport/flvicon.png' alt='Click here to play this video...' />";                                                                  
       }
       echo "</a>";
       echo "<script language='JavaScript' type='text/javascript'>";
       echo "flowplayer('videoplayer','flvsupport/flowplayer-3.1.5.swf');";
       echo "</script>";    
       }elseif ($imgrow[form] == 'EMB') {
       //this section is for embedded video types (e.g. youtube)
       $embedblurb = file_get_contents($rootpath . rawurldecode($mediasrc));
       $embedblurb = str_replace('"',"'",$embedblurb);
       echo $embedblurb;      
       }else{
       //this section is all other video types
       echo "<embed src=\"$mediasrc\"$widthstr$heightstr>\n";
}
//********************************* FLV and Embedded Video Mod by dlassen  ENDS HERE *********************************

6) create a folder named "/flvsupport" off of the main TNG folder

7) place the following files in the flv folder:

flowplayer-3.1.5.swf

flowplayer-3.1.4.min.js

flowplayer.controls-3.1.5.swf

NOTE: these files can be replaced by any version of the Flash Video player files. In case other versions are used, please remember to modify the mod code in showmedialib.php accordingly. In case anyone is interested, I have attached a zip file with the files I used - please note that the Flowplayer files are open sourced under the GPL license (I hope that releases me from any liability . Flash players can also be downloaded from http://flowplayer.org/ and or other sources.

7) place a png image in the /flvsupport folder named "flvicon.png" - this image will be displayed if no preview image is provided.

<END OF MOD STEPS>

Notes on how to use this mod:

FLV SUPPORT

=========

Upload FLV files as you would upload any other video file (either browse to upload or FTP to the media folder). If uploaded, the clickable image "flvicon.png" will be displayed on the video's page and can be clicked to play the video.

If you would like to display a specific preview image on the video's page, do the following (optional):

- after loading the video itself, upload the desired preview image to the TNG /media folder - NOTE: THIS MUST BE A JPG FILE

- rename this file to the same name as the video file but with the jpg extension, e.g.

if you uploaded "MyVideo.flv" name the image "MyVideo.jpg".

The mod will look for this jpg and (if present) display it on the video's page. When clicked, the video will play.

I like to display a preview image as this looks much nicer than the media player black box displayed in TNG. My preferred way of getting this image is to play the video stopping at the desired frame, take a screenshot, then crop it and save it as described above. This will give the appearance that video player itself is being displayed with a keyframe.

With regards to generating the FLV video file itself, I use the "Xilisoft FLV Converter" which can convert most formats to FLV including WMV files - it is easy to use.

EMBEDDED VIDEO SUPPORT (EG YOUTUBE)

=============================

Here is how to embed a youtube video:

1) locate the desired video on youtube

2) highlight and copy the "embed code" (found in the upper right hand portion of the youtube screen - looks something like "<object width="425" height=...")

3) paste the contents into a notepad file and name it with the extension "emb", e.g. "MyYoutubeVideo.emb"

4) In TNG, load this file as you would any other video file

5) Navigate to the video page in TNG and Voila: you have youtube on TNG!!

Note that the height and width settings in TNG will be ignored. Instead the settings in the EMB file will be used, so if there is a need to change the display size, simply edit the EMB file before loading onto TNG.

Please let me know if this works out for you.

Thanks

Dennis

UPDATE: 2/24 5:30 am PT: edited the code as there was a minor bug...

TNG_flv_support_files.zip

Link to comment
Share on other sites

  • 3 weeks later...
edwards-moore

Easy Way to Add Youtube Videos to TNG?

Allen

Allen, you can copy the embed code in youtube, then copy into a new history; then convert the history to a video. It works....

Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...
Allen Prunty

Eeeek! What's the "..." in the $rootpath part?? And how come Allen hasn't been back?

Sorry... I had some health issues that crept up on me.

Reason why I want to farm it off to youtube is to save $$$ on transfer bandwidth.

Allen

Link to comment
Share on other sites

  • 3 months later...

Good job. I just tried that with TNG V9 and one thing you have to do after the convert is to edit the video file and remove the name of the "local file". It automatically goes in when you put a TITLE of the video, so just remove it and leave the TITLE block empty. Save and test - yes, it works great! :)

Allen, you can copy the embed code in youtube, then copy into a new history; then convert the history to a video. It works....

Link to comment
Share on other sites

  • 2 months later...
  • 4 years later...
PaddyHorrigan

Hi Dennis, I followed your instructions but still cannot connect to youtube. When I click on the link I just get a dialogue box asking me for a program location.

My site is located at

http://www.paddyhorrigan.com/getperson.php?personID=I371&tree=ask101

and the login is guest with password guest.

The you tube video embed code is 

<iframe width="560" height="315" src="https://www.youtube.com/embed/-XMpDwcoTko" frameborder="0" allowfullscreen></iframe>

Any help would be greatly appreciated.

 

Link to comment
Share on other sites

On 24/02/2010 at 4:57 PM, Allen Prunty said:

Easy Way to Add Youtube Videos to TNG?

 

Allen

The embed code you get off YouTube goes into the Body Text field via the HTML tab.

Detailed instruction...

cap.jpg

Link to comment
Share on other sites

3 hours ago, manofmull said:

Check/tick the little box (external source), enter the YouTube URL and that's it.

Yes, linking the YouTube URL is another (and much easier) option provided you don't mind (your users) being *diverted to the YouTube website however if you prefer the video playing directly in your TNG website then embedding the YouTube code is the way to go :)

cap.jpg

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...