Search code examples
htmlvideotags

How can I show a text in <video> tag, if source of the video is not defined


On my html-page there is a tag, created programmatically with JS.
Creation of the tag is made in 2 steps:

  1. After step 1 in the DOM the next element appears:
<video autoplay="" style="width: 320px; height: 240px;">
<p>+++ Video inaccessible +++</p>
</video>

Now source of the video is not defined.

  1. The video source is assigned (when the reference will be received from a remote peer by webRtc):
userAV.audio.srcObject = event.streams[0];

But this step may occur or not.
My question is about the case then the reference will not be received.
The question is: how can I make a text instead of video to be appeared (for example - video inaccessible) between steps 1 and 2 ?

I have tried to do it as in step 1 - I have added

tag with a text (text node), but the text doesn't appear on the screen.
While I see that the region 320*240 is reserved for a video, but it is empty.


Solution

  •  <div id="video-container">
        <video style="width: 320px; height: 240px;" controls>
           <!-- No source defined -->
       </video>
          <div id="video-placeholder">
           Video is not available
           </div>
              </div>