Jump to content
Sign in to follow this  
lynkfs

video in embedded browser

Recommended Posts

I can't seem to be able to play video in the embedded browser

The test-code below works fine in any standalone browser, but not in the ide

// video
  var video1 : variant := new JObject;
  video1 := browserapi.document.createElement('video');
  self.handle.appendChild(video1);
  video1.outerHTML := #'
    <video class="div" src="video1.mp4" muted="true" playsinline="true"
     preload="auto" poster="" autoplay="" loop="true" width="' +
     InttoStr(self.width) + '"></video>';

There is link here which refers to disabled codecs in CEF4, would that be the cause ?

It also states that these codecs could be build manually. If so, it might be nice to include them

Share this post


Link to post
Share on other sites

The MP4 codecs are only license free in browsers (as long as users don't have to pay for the audio or video). In any other application the use of the most widely used MP4 codecs requires a commercial license.
Looks like that is the reason for the exclusion of mp4 in CEF4

It should be possible to write-your-own MP4 codec. There are a couple of interesting posts on the subject (post 1, post 2) and there is a rudimentary codec structure in the rtl (system.codec.)
However not in the complexity of what mp4 requires

Google has produced its own license free product : 'webm'
This is used in their own products (youtube) and by other main producers (netflix)

There are many online converters available to convert .mp4 files to .webm files

Using the TW3MediaPlayer component (smartcl.controls.mediaplayer) to see how that works :

procedure TForm1.InitializeForm;
var
  VPlayer : TW3MediaPlayer;
begin
  inherited;
  // this is a good place to initialize components

  VPlayer := TW3MediaPlayer.Create(self);
  VPlayer.SetBounds(20,20,800,500);

  if VPlayer.CanPlayType('video/webm','vp8, vp9') = msProbably then
    writeln('probably');
  if VPlayer.CanPlayType('video/webm','vp8, vp9') = msMaybe then
    writeln('maybe');
  if VPlayer.CanPlayType('video/webm','vp8, vp9') = msNo then
    writeln('no');

  VPlayer.Load('video1.webm');  //video1.mp4');

  var Button1 := TW3Button.Create(self);
  Button1.SetBounds(20,550,100,30);
  Button1.Caption := 'Play';
  Button1.OnClick := lambda VPlayer.Play; end;
end;

 

And indeed this plays videos in both standalone browsers and the ide

 

 

 

Share this post


Link to post
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.

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

Sign in to follow this  

×
×
  • Create New...