Jump to content


Photo

Smart 2.9.9 [alpha] is here!


  • Please log in to reply
30 replies to this topic

#21 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 08 October 2017 - 08:55 AM

I did not add it to the component palette yet as there are no docs and examples about it. I'm also waiting for Jon to make an example once he's done with the styling.

So at the moment you can test it by adding SmartCL.Controls.Mediaplayer to the uses clause and creating the components in code. But your guess is as good as mine when it comes to using it.

#22 ielite

ielite
  • Members
  • 723 posts

Posted 08 October 2017 - 06:30 PM

yeah, well, I gave it a go and all i ever get is "Media not supported errors". I tried all kinds of configurations

<p>
unit Form1;

interface

uses
SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms,
SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Memo,
SmartCL.Controls.RadioGroup, SmartCL.Controls.Panel, SmartCL.Controls.MediaPlayer;

type
TForm1 = class(TW3Form)
private
{$I 'Form1:intf'}
MP: TW3MediaPlayer;
Memo: TW3Memo;
procedure HandlePlay(Sender: TObject);
procedure HandlePlaying(Sender: TObject);
procedure HandleCanPlay(Sender: TObject);
procedure HandleProgress(Sender: TObject);
procedure HandleAudioAvailable(Sender: TObject);
procedure HandleMediaError (Sender: TObject; Err: TW3MediaError);
procedure HandleLoadStart(Sender: TObject);
procedure HandleLoadedData(Sender: TObject);
protected
procedure InitializeForm; override;
procedure InitializeObject; override;
procedure ObjectReady;override;
procedure Resize; override;
end;

implementation

{ TForm1 }

procedure TForm1.HandlePlay(Sender: TObject);
begin
Memo.Add('Play...');
End;

procedure TForm1.HandlePlaying(Sender: TObject);
begin
Memo.Add('Playing...');
End;

procedure TForm1.HandleCanPlay(Sender: TObject);
begin
Memo.Add('Can Play!');
End;

procedure TForm1.HandleProgress(Sender: TObject);
begin
Memo.Add('.');
End;

procedure TForm1.HandleAudioAvailable(Sender: TObject);
begin
Memo.Add('Audio Available!');
End;

procedure TForm1.HandleLoadStart(Sender: TObject);
begin
Memo.Add('Data Loading...');
End;

procedure TForm1.HandleLoadedData(Sender: TObject);
begin
Memo.Add('Data Loaded!');
End;

procedure TForm1.HandleMediaError (Sender: TObject; Err: TW3MediaError);
begin
Memo.Add(Err.message);
end;


procedure TForm1.InitializeForm;
begin
inherited;
// this is a good place to initialize components
end;

procedure TForm1.InitializeObject;
begin
inherited;
{$I 'Form1:impl'}
Memo:= TW3Memo.Create(self);

MP:= TW3MediaPlayer.Create(self);
MP.CanPlayType('video/mp4');
MP.OnPlay:= HandlePlay;
MP.OnPlaying:= HandlePlaying;
MP.OnLoadStart:= HandleLoadStart;
Mp.OnLoadedData:= HandleLoadedData;
MP.OnCanPlay:= HandleCanPlay;
MP.OnProgress:= HandleProgress;
MP.OnAudioAvailable:= HandleAudioAvailable;
MP.OnError:= HandleMediaError;
end;

procedure TForm1.ObjectReady;
begin
inherited;
Mp.Load('res\test.mp4');
Mp.Play;
end;

procedure TForm1.Resize;
begin
inherited;
MP.SetBounds(0,0,width,height Div 2);
Memo.SetBounds(0, height Div 2, width, height);
end;

initialization
Forms.RegisterForm({$I %FILE%}, TForm1);
end.
</p>

#23 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 11 October 2017 - 11:26 AM

Mp.Load('res\test.mp4'); With all file names, always use / instead of \ I haven't had time to test that one, but this is the same issue that happened with the backgrounds.

#24 ielite

ielite
  • Members
  • 723 posts

Posted 11 October 2017 - 05:47 PM

Yes, I did test that and it did not make a difference


&nbsp;

Mp.Load('res\test.mp4');With all file names, always use / instead of \I haven't had time to test that one, but this is the same issue that happened with the backgrounds.

&nbsp;

#25 ielite

ielite
  • Members
  • 723 posts

Posted 11 October 2017 - 05:47 PM

Yes, I did test that and it did not make a difference


&nbsp;

Mp.Load('res\test.mp4');With all file names, always use / instead of \I haven't had time to test that one, but this is the same issue that happened with the backgrounds.

&nbsp;

#26 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 14 October 2017 - 02:21 PM

Here's a quick test, which worked. There was no sound in the embedded chrome, but the browser worked well.

mp:=TW3MediaPlayer.Create(Self);
mp.SetBounds(0,0,Width,Height);
mp.OnLoadedData:=procedure(Sender: TObject)
begin
Writeln('Loaded!');
mp.Play;
end;
mp.Load('res/pumpupkicks.mp3');

I also tested with a mp4-file and that worked in the browser too. I guess the big trick is to call Play only after OnLoadedData has been triggered.
  • ielite likes this

#27 ielite

ielite
  • Members
  • 723 posts

Posted 14 October 2017 - 07:16 PM

<p>
I can't get that to work in my Alpha release

Using you exact code, i tried both an MP3 and an MP4

procedure TForm1.InitializeObject;
begin
inherited;
{$I 'Form1:impl'}
mp:=TW3MediaPlayer.Create(Self);
mp.SetBounds(0,0,Width,Height);
mp.OnLoadedData:=procedure(Sender: TObject)
begin
Writeln('Loaded!');
mp.Play;
end;
mp.Load('res/test.mp4');
end;
</P>

#28 jarto

jarto
  • Administrators
  • 72 posts
  • LocationVaasa, Finland
  • Enterprise Edition

Posted 14 October 2017 - 07:18 PM

Put it in TForm1.InitializeForm

#29 ielite

ielite
  • Members
  • 723 posts

Posted 14 October 2017 - 07:20 PM

<p>
If I do that, i get errors

Uncaught TypeError: Cannot read property 'FHandle$3' of null [line #5362]
Uncaught TypeError: Cannot read property 'FHandle$3' of null [line #5362]
</p>


&nbsp;

Put it in TForm1.InitializeForm

&nbsp;

#30 ielite

ielite
  • Members
  • 723 posts

Posted 14 October 2017 - 07:23 PM

<p>

The errors were because I had

procedure TForm1.Resize;
begin
inherited;
mp.SetBounds(0,0,Width,Height);
end;

I removed and and get no errors now, but neither file plays
</p>

#31 ielite

ielite
  • Members
  • 723 posts

Posted 14 October 2017 - 07:27 PM

ahhhh, if I play it outside of the IDE, it works, but it will not play for me inside the default browser from the IDE
  • Dennis07 likes this




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users