You are viewing our Forum Archives. To view or take place in current topics click here.
HTML help please
Posted:

HTML help pleasePosted:

Datdrop
  • New Member
Status: Offline
Joined: Jul 01, 201311Year Member
Posts: 2
Reputation Power: 0
Status: Offline
Joined: Jul 01, 201311Year Member
Posts: 2
Reputation Power: 0
I am looking for help with my website, i am wishing to have a video player on my webpage that will automatically play any video files uploaded to the same directory without hard coding each file into the webpages code if anyone can help me that would be great or if you know where i can find the answer to my problem
#2. Posted:
7en
  • V5 Launch
Status: Offline
Joined: Aug 16, 201212Year Member
Posts: 598
Reputation Power: 29
Status: Offline
Joined: Aug 16, 201212Year Member
Posts: 598
Reputation Power: 29
With HTML? No.

This could be done with PHP and JavaScript, but it wouldn't be simple, and honestly I'm not good enough a person to do it for you.
#3. Posted:
Status: Offline
Joined: Jul 09, 201014Year Member
Posts: 1,800
Reputation Power: 67
Status: Offline
Joined: Jul 09, 201014Year Member
Posts: 1,800
Reputation Power: 67
well i havent done anything like this with videos but i have made something where a user can upload files to the server then you can view them from there, not sure if thats what you are after or something like that?

if you are, then you will need to use PHP and MySQL.
#4. Posted:
jake000001111v2
  • Challenger
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
Here you go i made a quick php script to create video players for the amount of videos in the videos directory.

Pm me if you want the download link as TTG are mean with links.

Anyone can have it just PM me and ill send it to you.
#5. Posted:
iyop45
  • Prospect
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Well the most efficient way, as lightly suggested previously, is through a database. You can store all the video urls and upload dates then just call the most recent one and display it on the page.

I wouldn't recommend actually reading through the directory to find appropriate files as the whole purpose of tables is a work around for this.

What I mean is something like this:

CREATE TABLE `your_database`.`videos` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(30) NOT NULL,
  `video_url` VARCHAR(60) NOT NULL,
  `upload_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB;

And then query the table:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 1;
#6. Posted:
jake000001111v2
  • Challenger
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
iyop45 wrote Well the most efficient way, as lightly suggested previously, is through a database. You can store all the video urls and upload dates then just call the most recent one and display it on the page.

I wouldn't recommend actually reading through the directory to find appropriate files as the whole purpose of tables is a work around for this.

What I mean is something like this:

CREATE TABLE `your_database`.`videos` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(30) NOT NULL,
  `video_url` VARCHAR(60) NOT NULL,
  `upload_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB;

And then query the table:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 1;

My script just gets the videos and displays them each on individual video players which is what he wanted. The only ting with mine is the videos you upload you have to name them
1.mp4
2.mp4
3.mp4
ect...
but it works fine.
#7. Posted:
iyop45
  • Prospect
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
jake000001111v2 wrote
iyop45 wrote Well the most efficient way, as lightly suggested previously, is through a database. You can store all the video urls and upload dates then just call the most recent one and display it on the page.

I wouldn't recommend actually reading through the directory to find appropriate files as the whole purpose of tables is a work around for this.

What I mean is something like this:

CREATE TABLE `your_database`.`videos` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(30) NOT NULL,
  `video_url` VARCHAR(60) NOT NULL,
  `upload_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB;

And then query the table:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 1;

My script just gets the videos and displays them each on individual video players which is what he wanted. The only ting with mine is the videos you upload you have to name them
1.mp4
2.mp4
3.mp4
ect...
but it works fine.

I wasn't building his entire site I was simply explaining the best approach to the situation.

It's not efficient to read folders for the video files and display them accordingly as it can lead to integrity errors and is more difficult to maintain. Using a database is a lot more versatile than your 'said' approach and less server intensive, if you're really determined in reinventing the wheel go for it but what you're doing is trying to build dynamic content on a static page. If you think it's easier to read entire directories with potentially hundreds of videos than to simply perform a SELECT query and call a video(s) directly then by all means continue to do it your own way.

What you said your script does can be easily implemented for if the OP used a database. Have you ever thought the query could just be changed to:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 5;
#8. Posted:
jake000001111v2
  • Challenger
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 148
Reputation Power: 7
iyop45 wrote
jake000001111v2 wrote
iyop45 wrote Well the most efficient way, as lightly suggested previously, is through a database. You can store all the video urls and upload dates then just call the most recent one and display it on the page.

I wouldn't recommend actually reading through the directory to find appropriate files as the whole purpose of tables is a work around for this.

What I mean is something like this:

CREATE TABLE `your_database`.`videos` (
  `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `title` VARCHAR(30) NOT NULL,
  `video_url` VARCHAR(60) NOT NULL,
  `upload_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB;

And then query the table:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 1;

My script just gets the videos and displays them each on individual video players which is what he wanted. The only ting with mine is the videos you upload you have to name them
1.mp4
2.mp4
3.mp4
ect...
but it works fine.

I wasn't building his entire site I was simply explaining the best approach to the situation.

It's not efficient to read folders for the video files and display them accordingly as it can lead to integrity errors and is more difficult to maintain. Using a database is a lot more versatile than your 'said' approach and less server intensive, if you're really determined in reinventing the wheel go for it but what you're doing is trying to build dynamic content on a static page. If you think it's easier to read entire directories with potentially hundreds of videos than to simply perform a SELECT query and call a video(s) directly then by all means continue to do it your own way.

What you said your script does can be easily implemented for if the OP used a database. Have you ever thought the query could just be changed to:

SELECT title, video_url FROM videos ORDER BY upload_date DESC LIMIT 5;

I don't think you've ever used tables before as if you had you'd realize you're displaying such a null point.

Dude it only counts the number of files, and yea i have used tables but entering values in a table each time you upload a video to your server is effort i would rather upload it and i'm done.
<?php
$vidcount = count(glob("videos/" . "*"));

for($i=1;$i<$vidcount+1;$i++)
{
echo "<center><br/><h2>This is video $i</h2><br/>";
echo "<video id=\"example_video_1\" class=\"video-js vjs-default-skin\" controls preload=\"none\" width=\"640\" height=\"264\"";
echo "poster=\"http://video-js.zencoder.com/oceans-clip.png\"";
echo "data-setup=\"{}\">";
echo "<source src=\"videos/$i.mp4" type='video/mp4' />";
echo "</video><br/>";
echo "</center>";
}
?>
#9. Posted:
iyop45
  • Prospect
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
Status: Offline
Joined: Apr 15, 201113Year Member
Posts: 614
Reputation Power: 83
I guess I did sound a bit aggressive but my point is still valid. Your script assumes all files have an incrementing number in their file-name. If the user removes say file '2' and there are 5 mp4 files present it would still attempt to display file 2.

I will ignore the issue with embedding the $i variable within the echo statement for now but, what if the user changed the move file type, you would have to change your script. It isn't very flexible.

I think the inserting of rows overlooks the intensive maintenance and constant alteration of your script.

$movies_returned = 5;
if($stmt = $mysqli->prepare("SELECT title, video_url, file_type FROM videos ORDER BY upload_date DESC LIMIT '$movies_returned'")){
      $stmt->execute();
      $stmt->store_result();
      $stmt->bind_result($title, $video_url, $file_type);
      while($stmt->fetch()){
       echo 'Title: ' . $title . '
              <video width="320" height="240" controls>
                  <source src="' . $video_url . '" type="' . $file_type . '">
              </video>';
      }
}
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.