Browse Source

use more robust `is_file` check (fixes #2159)

Falko Schindler 1 năm trước cách đây
mục cha
commit
2b1cac9d67
2 tập tin đã thay đổi với 4 bổ sung4 xóa
  1. 2 2
      nicegui/elements/audio.py
  2. 2 2
      nicegui/elements/video.py

+ 2 - 2
nicegui/elements/audio.py

@@ -1,7 +1,7 @@
 from pathlib import Path
 from typing import Union
 
-from .. import core
+from .. import core, helpers
 from ..element import Element
 
 
@@ -27,7 +27,7 @@ class Audio(Element, component='audio.js'):
         for a list of events you can subscribe to using the generic event subscription `on()`.
         """
         super().__init__()
-        if Path(src).is_file():
+        if helpers.is_file(src):
             src = core.app.add_media_file(local_file=src)
         self._props['src'] = src
         self._props['controls'] = controls

+ 2 - 2
nicegui/elements/video.py

@@ -1,7 +1,7 @@
 from pathlib import Path
 from typing import Union
 
-from .. import core
+from .. import core, helpers
 from ..element import Element
 
 
@@ -27,7 +27,7 @@ class Video(Element, component='video.js'):
         for a list of events you can subscribe to using the generic event subscription `on()`.
         """
         super().__init__()
-        if Path(src).is_file():
+        if helpers.is_file(src):
             src = core.app.add_media_file(local_file=src)
         self._props['src'] = src
         self._props['controls'] = controls