mos Posted October 27, 2017 Share Posted October 27, 2017 Hi, Does unigui implement http 206 responses. We do not have the source code (.dcu files only) and when playing back audio to a user using html5 audio controls works on Firefox, Edge etc. If necessary I will have to use a flash player on Chrome browser just so that users can select the position to start playing recording from. On Chrome however, when you try to move the cursor towards the end on a audio file, the player restarts and goes back to the beginning. In the research that I have done, have posted the web server needs to implement range ranges and http 206 responses. Which brings me back to the original question.Based on a post on stackexchange I tried this in event handler UniGUIServerModuleHTTPCommand but does not seem to fire... (Is there a demo related to range requests and byte streaming?) filename := ARequestInfo.Document; if (Pos('/cache', filename) > 0) then begin StrReplace(filename, '/', '\', [rfReplaceAll, rfIgnoreCase]); filename := PathAppend(CacheFolderPath, filename); trace('TUniServerModule.UniGUIServerModuleHTTPCommand::filename=' + filename); stream := TFileStream.Create(filename, fmOpenRead or fmShareDenyNone); // THTTPServer parses the ranges for you if (ARequestInfo.Ranges.Count > 0) then begin if (ARequestInfo.Ranges.Count > 1) then begin AResponseInfo.ResponseNo := 416; Exit; end; range := ARequestInfo.Ranges[0]; rstream := TIdHTTPRangeStream.Create( stream, range.StartPos, range.EndPos, true); AResponseInfo.ResponseNo := rstream.ResponseCode; AResponseInfo.ContentRangeStart := rstream.RangeStart; AResponseInfo.ContentRangeEnd := rstream.RangeEnd; AResponseInfo.ContentStream := rstream; AResponseInfo.AcceptRanges := 'bytes'; end else begin AResponseInfo.ContentStream := stream; end; end; *) Link to comment Share on other sites More sharing options...
Sherzod Posted October 27, 2017 Share Posted October 27, 2017 Hi, On Chrome however, when you try to move the cursor towards the end on a audio file, the player restarts and goes back to the beginning. Can you make a simple testcase for this ?! Best regards, Link to comment Share on other sites More sharing options...
mos Posted October 28, 2017 Author Share Posted October 28, 2017 Steps to follow 1. add TUniHTMLFrame to main form 2. add TUniButton to main form 3. add code to button on click event procedure TMainForm.UniButton1Click(Sender: TObject);var script_: string;begin script_ := '<audio id="player1" controls> ' + '<source src="files/testfile3.wav" type="audio/wav"></source>' + '</audio>'; UniHTMLFrame1.HTML.Text := script_;end; (Now, testfile3.wav is the 23Mb but within browsers like firefox I can set the currentTime via js) On Chrome, and without any such code (that does not work, ie. only using the above) trying to tell the player to start 1/2 way through the recording just goes back to the beginning! While the following link is related the video, it also applies to audio... https://stackoverflow.com/questions/27964533/js-currenttime-for-html-video-tag-is-not-working-on-chrome which includes reply The problem (at least regarding Chrome) is probably on the server side. Put Header set Accept-Ranges bytes in your .htaccess (this this answer) which points to this post... https://stackoverflow.com/questions/9563887/setting-html5-audio-position/9565178#9565178 and https://developer.mozilla.org/en-US/docs/Web/HTTP/Configuring_servers_for_Ogg_media#Handle_HTTP_1.1_byte_range_requests_correctly Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now