0
我想弄清楚如何在html中顯示圖像或視頻。爲了澄清,我想顯示視頻,但如果視頻不存在或文件未找到,我想要顯示默認圖片。基本上是一個圖像文件顯示,如果視頻不會或不存在。這甚至有可能嗎?我一直試圖弄清楚這一點。沒有運氣。任何幫助,將不勝感激。選擇圖像或視頻
我想弄清楚如何在html中顯示圖像或視頻。爲了澄清,我想顯示視頻,但如果視頻不存在或文件未找到,我想要顯示默認圖片。基本上是一個圖像文件顯示,如果視頻不會或不存在。這甚至有可能嗎?我一直試圖弄清楚這一點。沒有運氣。任何幫助,將不勝感激。選擇圖像或視頻
檢出這段代碼,它提供HTML5視頻後備到Flash和Flash後備到簡單圖像,而不會涉及任何JavaScript!
<!-- first try HTML5 playback: if serving as XML, expand `controls` to `controls="controls"` and autoplay likewise -->
<!-- warning: playback does not work on iOS3 if you include the poster attribute! fixed in iOS4.0 -->
<video width="100%" height="200px" controls>
<!-- MP4 must be first for iPad! -->
<source src="__VIDEO__.MP4" type="video/mp4" /><!-- Safari/iOS video -->
<source src="__VIDEO__.OGV" type="video/ogg" /><!-- Firefox/Opera/Chrome10 -->
<!-- fallback to Flash: -->
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
<param name="movie" value="__FLASH__.SWF" />
<param name="flashvars" value="controlbar=over&image=__POSTER__.JPG&file=__VIDEO__.MP4" />
<!-- fallback image. note the title field below, put the title of the video there -->
<img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__"
title="No video playback capabilities, please download the video below" />
</object>
</video>
<!-- you *must* offer a download link as they may be able to play the file locally. customise this bit all you want -->
<p>
<strong>Download Video:</strong>
Closed Format: <a href="__VIDEO__.MP4">"MP4"</a>
Open Format: <a href="__VIDEO__.OGV">"Ogg"</a>
</p>