Tsalagi_4 has asked for the wisdom of the Perl Monks concerning the following question:

There are two lines of code that formats the entry into this field. In two places I had to replace the code like this.

$vidlect   = "$main::in{'vidlect'}" ; $vidlect =~ s/"/"/g

With this

$vidlect   = "$main::in{'vidlect'}" ; $vidlect =~ s/\0//;

Thanks for the attempt at helping

Hello. I have a program to take notes while watching online video lectures. It's a hassle alt+tabbing between the two windows all the time, so I thought I would hack the code to display video inside the notes editor mode. The program for taking notes is written in Perl. It has a form to save a new notes page to a file and then a form to edit those notes. I successfully added an input field to save the embed code from the You Tube lecture and save it to a variable but I cant get the video to show calling it from the variable in which the embed code is stored.

There are three modes. One to add a new note file, one to read the new note file and one to edit it. After I create a new notes file for a new lecture with the link to the video pasted in the input field I go into edit mode to enter my notes. It is during edit mode that I want to be able to view the video

Here is the code that saves the initial notes file.

# Write the new file out. my $strdate = gmtime( time ); open( FILE, ">$filename" ) || &InvalidFile(); print FILE <<EOF; <!-- Author: $author --> <!-- Date: $strdate (GMT) --> <!-- Title: $title --> <!-- Keywords: $kwords --> <!-- Video Lecture: $vidlect --> <!-- Changes: Modified $strdate (GMT) $author | $changes --> $body EOF

Here is the form code to edit the notes file

print <<EOF; <form action="$main::script" enctype="multipart/form-data" method=post +> <p> <pre> <b>Your name</b>: <input type=text name=author value="$author" size=40 /> <b>The title</b>: <input type=text name=title value="$title" size=40 /> <b>Keywords</b> : <input type=text name=keywords value="$kwords" size=40 /> (optional) <b>Video Lecture</b> : <input type=text name=vidlect value="$vidlect" size=140 /> </pre> </p> <textarea rows=15 cols=175 WRAP=SOFT name=body>$body</textarea><br> </p> EOF

I used two methods to test if the variables actually captured the code. Here they are.

print <<EOF; <div>$vidlect</div> EOF print <<EOF;

and

<div>$vidlect</div>

It may be worth noting that when I view source through the browser, the the video link code is html entities rather than the true html code. I don't know that much about Perl but other code may be changing the original link.

Thanks in advance for any help

Here is the link from youtube

<object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Pij6J0HsYFA&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Pij6J0HsYFA&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

Even with the size of 140 it seemed to be capturing the entire link code but I expaned it with the same result. Another thing of interest is that if I past the link code directly into the form, the lecture displays fine. Thanks for replying.

Replies are listed 'Best First'.
Re: Displaying Youtube Video
by marto (Cardinal) on Jun 11, 2010 at 11:47 UTC

    Can you post an example of what you have stored in $vidlect? If it's simply the URL to a youtube video you won't be able to view it on the page. To embed a youtube video you need the 'embed' code, which includes the flash player etc:

    <object width="425" height="344"> <param name="movie" value="http://www.youtube.com/v/GwQMnpUsj8I&hl=en& +fs=1"> </param><param name="allowFullScreen" value="true"> </param><param name="allowscriptaccess" value="always"> </param><embed src=http://www.youtube.com/v/GwQMnpUsj8I&hl=en&fs=1 type="application/x-shockwave-flash" allowscriptaccess="always" allowf +ullscreen="true" width="425" height="344"> </embed></object>

    You're restricting this to 140 characters in your text field.

    Update: confised size and maxlength. OP has updated their post

      I updated my original post first. Getting to know Perl Monks forum. Anyway here is the you tube link.

      <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/Pij6J0HsYFA&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Pij6J0HsYFA&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>

      Thanks for replying

        Don't worry about it, welcome to the Monastery. Could you post what the result of <div>$vidlect</div> displays?

      To embed a youtube video you need the 'embed' code, which includes the flash player etc

      Nah, that's just Nutscrape proprietary code that people use to placate teh Evil One.

      But you can still keep code valid: Bye Bye Embed.