简体   繁体   English

检查无线电流 url 是否与 Javascript 一起工作

[英]Check if a Radio Streaming url is working or not with Javascript

Hi I'm doing a website which contains several radios.您好我正在做一个包含几个收音机的网站。 I need to know, through javascript, if a radio stream url is working or not.我需要通过 javascript 知道收音机 stream url 是否工作。 I achieve this in PHP doing a file_get_contents($radio_source, false, NULL, -1, 600);我在 PHP 中实现了这一点,执行file_get_contents($radio_source, false, NULL, -1, 600); , doing this I know that if the request reached the limit (600) then the request is alive, otherwise, not. ,这样做我知道如果请求达到限制(600),那么请求是有效的,否则,不是。 My question is: Does exist a way to do this in Javascript?.我的问题是:在 Javascript 中是否存在这样做的方法? So far, $.ajax doesn't seems to be an option, because doesn't have any parameter to help me to achieve this.到目前为止, $.ajax 似乎不是一个选项,因为没有任何参数可以帮助我实现这一目标。

You can use this cool function built for javascript: https://github.com/kvz/phpjs/blob/master/functions/filesystem/file_get_contents.js .您可以使用为 javascript 构建的这个很酷的 function: https://github.com/kvz/phpjs/blob/master/functions/filesystem/file_get_contents.js That uses XMLHttpRequest使用 XMLHttpRequest

You could have the same code that you do in php now, but refer to it with an ajax request.您现在可以使用与 php 中相同的代码,但请通过 ajax 请求引用它。

I know you said no ajax, but I mean referring to the php file, not the radio stream.我知道你说没有 ajax,但我的意思是指 php 文件,而不是收音机 stream。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM