从文本文件中读取行/变量 javascript

发布于 2024-12-28 04:26:25 字数 379 浏览 4 评论 0原文

所以我一直在玩一个使用 javascript 来选择要播放的文件的媒体播放器,我想知道是否可以有一个包含视频文件名的外部文件,并且 javascript 只会读取一行并使用作为当前视频来播放?

我当前选择要播放的视频文件的 JS 行是这样的:

playMovie('http://URL.tld/videos/videoFile.flv');

现在这工作正常,但不必一直编辑它,我想只编辑一个文本文件并使其像这样:

playMovie('http://URL.tld/videos/'+fileName+'.flv');

但不仅仅是作为一个变量,它将是文本文件中的一行。

谢谢

So I've been playing around with a media player that uses javascript to choose which file to play, I was wondering if i could have an external file that has the video file names in it, and the javascript will just read one line and use that as the current video to play?

my current JS lines that chooses which video files to play is this:

playMovie('http://URL.tld/videos/videoFile.flv');

Now this works fine, but instead of having to edit this all the time I'd like to just edit a text file and have it something like this:

playMovie('http://URL.tld/videos/'+fileName+'.flv');

but instead of just being a variable, it'll be a line from a text file.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜声 2025-01-04 04:26:25

您无法使用 javascript 读取文件,但您可以将 ajax 调用发送到可以读取文件的服务器页面。

You can't read files with javascript, but you can send ajax calls to a server page that can.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文