[Pas2js] project SaintClaus for pas2js 1.5.1

warleyalex warleyalex at yahoo.com.br
Thu Oct 17 03:39:38 CEST 2019


The new changes:
===========
type
  TJSAudio = class external name 'Audio' (TJSHTMLAudioElement) 
  public
    constructor New(src: String); overload;
  end;

procedure PlaySound(snd: TJSHTMLAudioElement);
begin
  if snd.paused then
    snd.play()
  else
    snd.currentTime := 0;
end;   

{  The audio work for me if I define GetSound method this way. }

function GetSound(fileName: String; loop: Boolean): TJSAudio;
var
  snd: TJSAudio;
begin
  snd := TJSAudio.new(fileName);
  snd.loop := loop;
  GetSound := snd;
  Result := snd;
end; 

  (...)
  PlaySound( GetSound('assets/jingle_bells.mp3', true) ); // the audio play
for me without errors :)


[quote] The class is not Audio, but HTMLAudioElement. [/quote]

--> if the GetSound method return the TJSHTMLAudioElement instead of
TJSAudio, I've got "Illegal constructor" console error, the audio does not
play for me :)




--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list