Jump to content

Chrome and Audio Seek Problem/Question


Recommended Posts



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
    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
        if (ARequestInfo.Ranges.Count > 1) then
            AResponseInfo.ResponseNo := 416;

        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';
      AResponseInfo.ContentStream := stream;
  end;  *)

Link to comment
Share on other sites

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);
  script_: string;
  script_ :=
    '<audio id="player1" controls> ' +
    '<source src="files/testfile3.wav" type="audio/wav"></source>' +
  UniHTMLFrame1.HTML.Text := script_;

(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...




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...







Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...