Page 1 of 1

Plyr VideoPlayer error

Posted: Sun Jun 13, 2021 4:35 pm
by skinkairewalker
hello everyone !!

i am trying Plyr VideoPlayer ( https://github.com/sampotts/plyr ) to learn about videos and stream
using this code below, when i run :

Code: Select all

Procedure AppendHead(content.s)
  Debug "head"
  !$("head").append(v_content);
EndProcedure

Procedure AppendBody(content.s)
  !$("body").append(v_content);
EndProcedure

Procedure AppendContent(component.i,content.s, Position = #PB_Ignore)
  GID = GadgetID(component)
  If Position <> #PB_Ignore
    ! $(".card:eq(" + v_position + ")").prepend(v_content);
  Else
    ! $(v_gid.div).append(v_content);
  EndIf
EndProcedure


;Procedure AppendBody(content.s)
;  !$("body").append(v_content);
;EndProcedure

Procedure Main()
  
            AppendBody("<div id='player' data-plyr-provider='youtube' data-plyr-embed-id='bTqVqk7FSmY'></div>")
            
            !const player = new Plyr('#player', {});
            !window.player = player;
            
  
EndProcedure

Global nLoaded
Global nImports = 3

Procedure RequireScript(url.s, objName.s)
  Debug "require entrou"
;  EnableJS
!  require([v_url], function(obj) {
!    window[v_objname] = obj;
!    v_nloaded++;
!    if (v_nloaded == v_nimports) {
!      f_main();
!    }
!  });
;  DisableJS
EndProcedure

Procedure ExternalLoaded(URL$, Success)
  ;Static nLoaded
  Debug "entrou"
  If Success
    nLoaded + 1
    If nLoaded = nImports ; the number of files to import
      Main()
    EndIf
  Else
    Debug "Failed to load external: " + URL$
  EndIf
EndProcedure

; LoadScript("https://cdn.plyr.io/3.6.8/plyr.polyfilled.js", @ExternalLoaded(), #PB_Script_JavaScript)
RequireScript("https://cdn.plyr.io/3.6.8/plyr.polyfilled.js", "Plyr") 
LoadScript("https://cdn.plyr.io/3.6.3/plyr.css", @ExternalLoaded(), #PB_Script_CSS)
LoadScript("https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css", @ExternalLoaded(), #PB_Script_CSS)
LoadScript("https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js", @ExternalLoaded(), #PB_Script_JavaScript)
show this errors :https://prnt.sc/15a7bqz
why does this occur?

Re: Plyr VideoPlayer error

Posted: Sun Jun 13, 2021 5:09 pm
by Peter
Always try to reduce the code to the bare minimum in case of problems. This works for me:

Code: Select all

Procedure Main()
  
  ! $("body").append("<div id='player' data-plyr-provider='youtube' data-plyr-embed-id='bTqVqk7FSmY'></div>");
  ! const player = new Plyr('#player', {});
  ! window.player = player;
  
EndProcedure

Global nImports = 2

Procedure ExternalLoaded(URL$, Success)
  Static nLoaded
  Debug "entrou"
  If Success
    nLoaded + 1
    If nLoaded = nImports ; the number of files to import
      Main()
    EndIf
  Else
    Debug "Failed to load external: " + URL$
  EndIf
EndProcedure

! define = null;

LoadScript("https://cdn.plyr.io/3.6.8/plyr.js",  @ExternalLoaded(), #PB_Script_JavaScript)
LoadScript("https://cdn.plyr.io/3.6.3/plyr.css", @ExternalLoaded(), #PB_Script_CSS)

Re: Plyr VideoPlayer error

Posted: Sun Jun 13, 2021 7:53 pm
by skinkairewalker
works fine !!!
you are the man, Peter!

but I solved it, just adding the

Code: Select all

define = null
what would >

Code: Select all

define = null
?


full code :

Code: Select all


Procedure AppendHead(content.s)
  Debug "head"
  !$("head").append(v_content);
EndProcedure

Procedure AppendBody(content.s)
  !$("body").append(v_content);
EndProcedure

Procedure AppendContent(component.i,content.s, Position = #PB_Ignore)
  GID = GadgetID(component)
  If Position <> #PB_Ignore
    ! $(".card:eq(" + v_position + ")").prepend(v_content);
  Else
    ! $(v_gid.div).append(v_content);
  EndIf
EndProcedure

Procedure Main()

            AppendBody("<div id='player' data-plyr-provider='youtube' data-plyr-embed-id='bTqVqk7FSmY'></div>")
            
            !const player = new Plyr('#player', {});
            !window.player = player;
  
EndProcedure

Global nLoaded
Global nImports = 4

Procedure ExternalLoaded(URL$, Success)
  ;Static nLoaded
  Debug "entrou"
  If Success
    nLoaded + 1
    If nLoaded = nImports ; the number of files to import
      Main()
    EndIf
  Else
    Debug "Failed to load external: " + URL$
  EndIf
EndProcedure

; just add this line below
! define = null;

LoadScript("https://cdn.plyr.io/3.6.8/plyr.js",  @ExternalLoaded(), #PB_Script_JavaScript)
LoadScript("https://cdn.plyr.io/3.6.3/plyr.css", @ExternalLoaded(), #PB_Script_CSS)
LoadScript("https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css", @ExternalLoaded(), #PB_Script_CSS)
LoadScript("https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.bundle.min.js", @ExternalLoaded(), #PB_Script_JavaScript)