问题
When I'm embedding a Youtube video into my website, the following error occurs:
An error occurred. Please try again later. (Playback ID: 044VSn6cAs2PR3y3) Learn More
My index.html
contains the following markup snippet:
<div class="mu-about-us-right">
<a id="mu-abtus-video" href="https://www.youtube.com/embed/watch?v=lWz-46NPqdk" target="youtube-video">
<img src="assets/img/about-us.jpg" alt="img">
</a>
</div>
I can't understand what is the error in my code. I have tried with some other videos as well so it's not a fault of Youtube server.
PS: I'm running my website on localhost
回答1:
Try embedding the video using an iframe like so:
<div class="mu-about-us-right">
<iframe width="560" height="315" src="https://www.youtube.com/embed/lWz-46NPqdk" frameborder="0" allowfullscreen></iframe>
</div>
You can't use an anchor tag to embed videos.
回答2:
My browsers were blocking the embedded content until I used this extension.
Install
pip install sphinxcontrib.yt
conf.py
extensions = [
, 'sphinxcontrib.yt'
]
file.rst
.. youtube:: bmbnPvSHcu4
来源:https://stackoverflow.com/questions/55556087/html-trying-to-embed-youtube-video