videogular / ngx-videogular

The HTML5 video player for Angular 2 and successor to videogular2
MIT License
126 stars 33 forks source link

Issue with Fullscreen Change Event Handling on iOS Leading to TypeError: Cannot Read Properties of Undefined #145

Open bissaye opened 3 days ago

bissaye commented 3 days ago

Description

There is an issue with the VgFullscreenApiService in the videogular-ngx-videogular-core.mjs file, specifically related to the handling of the fullscreen change event on iOS. When the polyfill for webkitendfullscreen is used, the code attempts to access this.medias.toArray()[0].elem, which can be undefined and leads to a TypeError: Cannot read properties of undefined. This issue causes the application to crash on iOS devices when attempting to enter or exit fullscreen mode.

Expected Behavior

The fullscreen change event should be handled correctly on iOS devices without causing any errors. The application should be able to enter and exit fullscreen mode smoothly.

Actual Behavior

On iOS devices, the application crashes with the error TypeError: Cannot read properties of undefined (reading 'elem') when attempting to handle the fullscreen change event.

Steps to Reproduce

  1. Set up a project with Videogular and ensure it is running on iOS (Safari or a web view).
  2. Implement a fullscreen functionality using Videogular.
  3. Attempt to enter or exit fullscreen mode on an iOS device.
  4. Observe the error in the console: TypeError: Cannot read properties of undefined (reading 'elem').
bissaye commented 3 days ago

i think that we just have to replace fsElemDispatcher =this.medias.toArray()[0].elem ; by fsElemDispatcher = this.medias.length > 0 ? this.medias.toArray()[0].elem : elem;

how can i contribute