Hello
I found a post about this on this forum, but I cant understand how to make it work and the topic is closed, so this is why I ask here.
Please someone tell me, how can I make it work with a simple example, or anything…
The post was this:
Ok, you’ll need to set your server up such that
your videos cannot be directly reached by the webserver. For example,
on a Media Temple server each of your sites is in a folder with the
domain name, say “myvideosite.com” and in that folder they set up an
html folder, and the website lives in that folder. You can put your
videos in the “myvideosite.com” folder at the same level as html.
In the page that presents your video start the session and get its id.
session_start();
$sid = session_id();
Now, for each video you’re going to display hash its server side path and the session id.
md5 is safe here as long as you don’t include the full path to the
video from the root - the path from the videos folder on down should be
sufficient. If there aren’t many videos that might just be a file name.
Now, when giving the link you use the hash instead of the real name.
Your index page can now look up the video the user want’s from the session variable.
$path = $_SESSION[$_GET[‘video’]];
The web server destroys the session variable when the browser is
closed or when a certain amount of time has elapsed without a page load -
by default 24 minutes. This can be changed in the PHP ini file.
This works because the session id is needed to build the hash. Even
if they copy the URI, the path stops working when the session expires.
If they start a new session they’ll get new URI’s. You will need to
pass your videos through PHP using the streaming functions, but that’s
another topic.
I cant understand how I need to set up this, because my language is not english.
I just try to make a working example, where I play the “relax3.mp4” but with my code it is not working yet and I not understand the logic way, how it need to be work.
So you uploaded the video to the wrong place. The HTML page needs to be where it can be accessed by visitors. The video needs to be in a folder at a higher level where it is not directly accessible and where it can only be accessed via a relative reference from the web page.
Thanks, it is working at now with your example, but I like to make the html5 player as in the post what I shared in my first post. Can you give me the second step?
To summarize, there is the “your_video_folder” above the site root.
The contents of this folder can not be accessed directly from a browser.
A file that can be accessed from the browser can get the files and serve them to the browser.
Leaving the “your_video_folder” alone, you can now have the “the_new_test_file” process POST, COOKIE, SESSION, GET values to control what file if any to serve.
To “the_new_test_file” add some conditional tests and some “else” code so it looks like this
Thanks, it is okay, but I interesting the solution what I shared in my first post, when I can use the html5 video/audio player. Your example is total different I think… or not?
I prefer to think of it as preliminary rather than totally different. Getting there. After this it’s a simple matter of using SESSION instead of GET
If those links work as far as being able to display the video when, and only when, the URL has the correct GET you can now replace the links with the video and source tags and make sure that works.
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Videos Above Root Test</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style type="text/css">
</style>
<script type="application/javascript">
// script needed before the DOM is loaded here
</script>
</head>
<body>
<h1>Videos Above Root Test</h1>
<video controls>
<source src="the_new_test_file?show_the_video=ABC123" type="video/mp4">
</video>
<script type="application/javascript">
// script that needs the DOM to be loaded here
</script>
</body>
</html>