0

I can play video files from a IIS web server to a client web app as long as they reside in the webroot directory on the server. I would like to play them from a shared directory not in the webroot, however. Is this possible?? Javascript function calling up video file, Videos is share name:

function loadAnotherVideo() {
var video = document.getElementById("video");
var source = document.getElementById("fileSelector");
var path = "//192.168.0.18/Videos/" + source.value;
alert(path);
video.src = path;
video.load();
video.play();

}

James Autry
  • 71
  • 1
  • 6

1 Answers1

0

You should be able to do something like this, just make sure the App Pool has reading rights on the folder where the file is stored

File - video.aspx
private void Page_Load(object sender, System.EventArgs e)
{
    //Set the appropriate ContentType.
    Response.ContentType = "video/mp4";

    //Get the physical path to the file.
    string FilePath = "c:\path-to-video\video.mp4";

    //Write the file directly to the HTTP content output stream.
    Response.WriteFile(FilePath);

    Response.End();
}
HTML
<video width="320" height="240" controls>
  <source src="video.aspx" type="video/mp4">
  Your browser does not support the video tag.
</video>

Based on a comment

Here is a post showing how to set/change a video source using javascript:

Community
  • 1
  • 1
Ason
  • 79,264
  • 11
  • 79
  • 127
  • If the file was selected through an html select control, can this be utilized on an onchange event?? Through ajax?? – James Autry Apr 10 '17 at 02:35
  • @JamesAutry Yes, the httprequest response could give you the path to the video and then set it to a video's src property, and here is how to change a video src: http://stackoverflow.com/questions/5235145/changing-source-on-html5-video-tag – Ason Apr 10 '17 at 06:13
  • Yes, that appears to work with videos in the webroot directory, but not with videos in a users videos directory. – James Autry Apr 10 '17 at 18:04
  • @JamesAutry Well, you need to combine the two techniques, then it will work – Ason Apr 10 '17 at 18:09