lib.web.mvc - Range Request in ASP.NET MVC - Failed to play with Google browser and Opera -
i'm using library here , i'm using plugin here play video.
follow code:
controller:
[httpget] public actionresult streamuploadedvideo() { byte[] test = null; using (var ctx = new entities()) { var result = ctx.table.where(x => x.field == 4).firstordefault(); test = result.movie; return new rangefilecontentresult(test, "video/mp4", "name.mp4", datetime.now); } }
view:
<video id="my-video" class="video-js" controls preload="auto" width="640" height="264" poster="my_video_poster.jpg" data-setup="{}"> <source src="@url.action("streamuploadedvideo","controller")" type='video/mp4'> <p class="vjs-no-js"> view video please enable javascript, , consider upgrading web browser <a href="http://videojs.com/html5-video-support/" target="_blank">supports html5 video</a> </p> </video>
problem: when change video time (example: change time 1:00 10:00 minutes), face problem below:
google chrome: a network error caused media download fail part-way.
opera: the media playback aborted due corruption problem or because used features browser did not support.
image:
the rest of browsers fine. google , opera latest updated version of today's date: 07/04/2017
micrososft edge - ok
firefox - ok
internet explorer - ok
opera - error
google - error
any solution ?
there issue code using datetime.now
modificationdate
used generating etag
, last-modified
headers. chromium (engine behind chrome , opera) range requests can conditional (which means can contain if-match
/if-none-match
/if-modified-since
/if-unmodified-since
) results in 412 precondition failed
instead of 200 ok
or 206 partial content
. if underlying content doesn't change should using same date, this.
[httpget] public actionresult streamuploadedvideo() { byte[] test = null; datetime lastmodificationdate = datetime.minvalue; using (var ctx = new entities()) { var result = ctx.table.where(x => x.field == 4).firstordefault(); test = result.movie; lastmodificationdate = result.lastmodificationdate; } return new rangefilecontentresult(test, "video/mp4", "name.mp4", lastmodificationdate); }
Comments
Post a Comment