admin管理员组文章数量:1406937
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 :
- Is it possible for
video
element to have nosrc
attribute. - If possible, how to get
src
for that video
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 :
- Is it possible for
video
element to have nosrc
attribute. - If possible, how to get
src
for that video
-
src
orsource
? – David R Commented Sep 15, 2016 at 10:39 - <video autoplay="" src="???" id="EKA-e2RERLzhCFy8AAEd" class="videoRoom"></video> – Aman Gupta 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
– evolutionxbox Commented Sep 15, 2016 at 10:42 - document.getElementById('EKA-e2RERLzhCFy8AAEd').src produces "" . – Aman Gupta Commented Sep 15, 2016 at 10:45
2 Answers
Reset to default 7Is 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.
<div class="col-sm-12">
<video width="400" controls>
<source src="http://ia800803.us.archive/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>
本文标签: javascriptHTML5Video element without 39src39 attributeStack Overflow
版权声明:本文标题:javascript - HTML5 : Video element without 'src' attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744973865a2635399.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论