javascript - Loading a file path from a text file and inputting it as the source for a video -
i have been trying hardest not have ask here. but, alas... cannot thing work. python programmer have briefest of requirements output in html. dont have time dig jquery , understand syntax, have been trying "bodge" it... alas... no joy!
i have written maltego transform in python creates concatonated path (source + entity name) , outputs text file. pass entity web browser redirects user video display page. need import text file using jquery, slot path text file variable , drop variable src video.
basic html, sole purpose enable user click full screen on video @ end of series of transforms finds videos associated entity name. nothing fancy.
the file contains path called "path.txt".
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <body> <video id="video1" width="520" height="440" src="" type="video/mp4" controls> <source src="" type="video/mp4"> </video> <script> $('#video1').load("path.txt", function(response) { var path = response; $("#video1").attr("src", path); alert(path); }); </script> </body> </body> </html>
this going want kick myself in shin over... if clear me (and explain!) appreciated.
as pointed out, js syntax incorrect. have other errors in html should noted however. center
tag deprecated: use margin (auto) instead. also, don't think source requires id. made fiddle (or can run snippet). have create path.txt , load in order function work
function load_file() { $("#loglist").load("path.txt", function(response) { var path = response; $("#video1").attr("src", path); alert("test " + path); }); }
video { margin-right: auto; margin-left: auto; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <body> <input type="button" value="load" onclick="load_file()" /> <video id="video1" width="520" height="440" src="" type="video/mp4" controls> <source src="" type="video/mp4"> </video> </body>
Comments
Post a Comment