Answer the question
In order to leave comments, you need to log in
How to determine if there is a video broadcast on the site?
The company's server is hosted by Adobe flash media streaming server. On the site - JWPlayer
The task is to show the player only when there is a video broadcast.
The server is not shutting down. Those. there is no point in pinging him.
Now we did this: we connect the stream to the JWPlayer. Waiting for a second to load. If the stream has not loaded, we react to the event - we hide the player. This is very suboptimal.
What do you think?
Answer the question
In order to leave comments, you need to log in
Did you try to check the connection to the stream port on the server side at the time of page generation?
Another option is to check the port via xmlhttprequest on the client side. ( xmlhttprequest.ru ) and show the player only by code 200.
Alexufo , and done. About this and the question) Google, so far, has not helped in any way, maybe someone here with experience in such a matter
JWPlayer has an API forwarded to JavaScript from Flash and there it is possible to subscribe to an error event, including an error in accessing the video stream, more details here .
I'm at home, to check for the presence of a stream, I do this.
rate=$(timeout 5 ffprobe "rtmp://localhost/live/rrstudio" 2>&1 | grep framerate | awk '{printf "%d", $2}')
if [ -z "$rate" ]; then
echo "$d: need restart - null rate $rate" >> /var/log/upstart/rrvideo.log
service rrvideo restart
elif [ $rate -lt 25 ]; then
echo "$d: need restart - $rate" >> /var/log/upstart/rrvideo.log
service rrvideo restart
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question