Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
112 views
in Technique[技术] by (71.8m points)

html - Return to original page after PHP script send video


Is there a way to jump back to original page after video has finished playing? I call PHP from link to video in HTML

...
<a href="play.php">My Video
...

and play.php sends back video like this:

<?php
$CTYP= 'video/mp4';
$VidPath = "../MyVideo.mp4";  
header('Content-Type: ' . $CTYP);
$VidFl = fopen($VidPath, "rb");
$VidContent = fread($VidFl, filesize($VidPath));
fclose($VidFl);
echo $VidContent; 
?>

Thanks

question from:https://stackoverflow.com/questions/65917999/return-to-original-page-after-php-script-send-video

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Final update for anyone who has a similar problem, It is now working version with original approach modified based on suggestions (should've probably read more carefully to avoid running around the solution:).

so index.html with <video> tags

....
<tr><td>
  <video height="auto" width="200" controls >
    <source src="play.php?play_video=101" type="video/mp4"> 
 </video>        
</td> <td>Lecture 101....</td>
</tr><tr><td>
  <video height="auto" width="200" controls >
    <source src="play.php?play_video=102" type="video/mp4">
  </video>        
</td> <td>Lecture 102....</td> 
</tr>
....

and play.php return stream like originally to href link tag

<?php
include 'dblog.php';
if ( ($_SERVER['REQUEST_METHOD'] === "GET")
     && ( isset($_GET['play_video']) ) ) {
  if ($_GET['play_video'] == "101")  {
    $file_path_name = "../../DVD/Lecture-101.mp4";
  } elseif ($_GET['play_video'] == "102") {
    $file_path_name = "../../DVD/Lecture-102.mp4";
  }
  $ctype= 'video/mp4';
  header('Content-Type: ' . $ctype);
  $handle = fopen($file_path_name, "rb");
  $contents = fread($handle, filesize($file_path_name));
  fclose($handle);
  write_vid_log($_GET['play_video'], $DB, 'start');
  echo $contents; 
} else {
  echo "alert(I'm Sorry wrong link)";
}
?>

So now works to be able to supply links outside of www root folder, and it plays video when client clicks. A few more challenges:

  • links to media files are easy downloadable, even though path, and file name is not shown, so I need use PHP script to check user and his rights before streaming video file
  • use CSS to resize and center video over the page, once clicked to play, and can be made seen as if it's playing in the lightbox. Looks like this is possible even without any JS

Any extra suggestions, would be appreciated


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...