1

I am using one of the webrtc libraries to show video and attaching the stream received to video element. But when I inspect the video element, src attribute is missing.

<video autoplay="" id="EKA-e2RERLzhCFy8AAEd" class="videoRoom"></video>

I have couple of questions here :

  1. Is it possible for video element to have no src attribute.
  2. If possible, how to get src for that video
4
  • src or source ? Commented Sep 15, 2016 at 10:39
  • <video autoplay="" src="???" id="EKA-e2RERLzhCFy8AAEd" class="videoRoom"></video> Commented Sep 15, 2016 at 10:42
  • 1
    Please try to keep it to one question per post. --- 1. yes, this can be assigned using JS, although it should show up in dev tools. --- 2. Try document.getElementById('EKA-e2RERLzhCFy8AAEd').src Commented Sep 15, 2016 at 10:42
  • document.getElementById('EKA-e2RERLzhCFy8AAEd').src produces "" . Commented Sep 15, 2016 at 10:45

2 Answers 2

7

Is it possible for video element to have no src attribute.

Yes it's possible.

The library you do use probably sets the srcObject property of your videoElement.

This property allows to set the source of your video directly to a MediaStream, a MediaSource, a Blob or a File Object. Note that FF only supports MediaStreams currently.

Example for FF (inspect the element afterward)

navigator.mediaDevices.getUserMedia({video:true}).then(s=>(vid.srcObject = s));
<video id="vid" controls></video>

And a fiddle for chrome since it requires https protocol for GUM to work.


If possible, how to get src for that video

Well, there is not really an src so I'd say not possible.

You can still call yourVideoElement.srcObject, but this will return the object to what it was set (usually a MediaStream).
If you need to record it, you can then use a MediaRecorder.

Sign up to request clarification or add additional context in comments.

1 Comment

Ya it helps. Can get my work done with srcObject also.
0

<div class="col-sm-12">
         
        <video width="400" controls>
          <source src="http://ia800803.us.archive.org/17/items/MickeyMouse-RunawayTrain/Film-42.mp4" type="video/mp4">           
        </video>
      </div>

In src place the video url you want

<video width="400" controls>
    <source src="" type="video/mp4">           
</video>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.