streamlit-nightly 1.33.1.dev20240422__py2.py3-none-any.whl → 1.33.1.dev20240423__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,6 +30,8 @@ from streamlit.proto.Audio_pb2 import Audio as AudioProto
30
30
  from streamlit.proto.Video_pb2 import Video as VideoProto
31
31
  from streamlit.runtime import caching
32
32
  from streamlit.runtime.metrics_util import gather_metrics
33
+ from streamlit.runtime.scriptrunner import get_script_run_ctx
34
+ from streamlit.runtime.state.common import compute_widget_id
33
35
  from streamlit.time_util import time_to_seconds
34
36
 
35
37
  if TYPE_CHECKING:
@@ -69,6 +71,7 @@ class MediaMixin:
69
71
  sample_rate: int | None = None,
70
72
  end_time: MediaTime | None = None,
71
73
  loop: bool = False,
74
+ autoplay: bool = False,
72
75
  ) -> DeltaGenerator:
73
76
  """Display an audio player.
74
77
 
@@ -118,6 +121,11 @@ class MediaMixin:
118
121
  e.g. ``timedelta(seconds=70)``.
119
122
  loop: bool
120
123
  Whether the audio should loop playback.
124
+ autoplay: bool
125
+ Whether the audio should start playing automatically.
126
+ Browsers will not autoplay audio files if the user has not interacted with
127
+ the page yet, for example by clicking on the page while it loads.
128
+ Defaults to False.
121
129
 
122
130
  Examples
123
131
  --------
@@ -183,6 +191,7 @@ class MediaMixin:
183
191
  sample_rate,
184
192
  end_time,
185
193
  loop,
194
+ autoplay,
186
195
  )
187
196
  return self.dg._enqueue("audio", audio_proto)
188
197
 
@@ -196,6 +205,8 @@ class MediaMixin:
196
205
  subtitles: SubtitleData = None,
197
206
  end_time: MediaTime | None = None,
198
207
  loop: bool = False,
208
+ autoplay: bool = False,
209
+ muted: bool = False,
199
210
  ) -> DeltaGenerator:
200
211
  """Display a video player.
201
212
 
@@ -263,6 +274,15 @@ class MediaMixin:
263
274
  e.g. ``timedelta(seconds=70)``.
264
275
  loop: bool
265
276
  Whether the video should loop playback.
277
+ autoplay: bool
278
+ Whether the video should start playing automatically.
279
+ Browsers will not autoplay video files if the user has not interacted with
280
+ the page yet, for example by clicking on the page while it loads.
281
+ To enable autoplay without user interaction, you can set muted=True.
282
+ Defaults to False.
283
+ muted: bool
284
+ Whether the video should play with the audio silenced. This can be used to
285
+ enable autoplay without user interaction. Defaults to False.
266
286
 
267
287
  Example
268
288
  -------
@@ -314,7 +334,6 @@ class MediaMixin:
314
334
  for more information.
315
335
 
316
336
  """
317
-
318
337
  start_time, end_time = _parse_start_time_end_time(start_time, end_time)
319
338
 
320
339
  video_proto = VideoProto()
@@ -328,6 +347,8 @@ class MediaMixin:
328
347
  subtitles,
329
348
  end_time,
330
349
  loop,
350
+ autoplay,
351
+ muted,
331
352
  )
332
353
  return self.dg._enqueue("video", video_proto)
333
354
 
@@ -434,6 +455,8 @@ def marshall_video(
434
455
  subtitles: SubtitleData = None,
435
456
  end_time: int | None = None,
436
457
  loop: bool = False,
458
+ autoplay: bool = False,
459
+ muted: bool = False,
437
460
  ) -> None:
438
461
  """Marshalls a video proto, using url processors as needed.
439
462
 
@@ -467,12 +490,22 @@ def marshall_video(
467
490
  The time at which this element should stop playing
468
491
  loop: bool
469
492
  Whether the video should loop playback.
493
+ autoplay: bool
494
+ Whether the video should start playing automatically.
495
+ Browsers will not autoplay video files if the user has not interacted with
496
+ the page yet, for example by clicking on the page while it loads.
497
+ To enable autoplay without user interaction, you can set muted=True.
498
+ Defaults to False.
499
+ muted: bool
500
+ Whether the video should play with the audio silenced. This can be used to
501
+ enable autoplay without user interaction. Defaults to False.
470
502
  """
471
503
 
472
504
  if start_time < 0 or (end_time is not None and end_time <= start_time):
473
505
  raise StreamlitAPIException("Invalid start_time and end_time combination.")
474
506
 
475
507
  proto.start_time = start_time
508
+ proto.muted = muted
476
509
 
477
510
  if end_time is not None:
478
511
  proto.end_time = end_time
@@ -531,6 +564,23 @@ def marshall_video(
531
564
  f"Failed to process the provided subtitle: {label}"
532
565
  ) from original_err
533
566
 
567
+ if autoplay:
568
+ ctx = get_script_run_ctx()
569
+ proto.autoplay = autoplay
570
+ id = compute_widget_id(
571
+ "video",
572
+ url=proto.url,
573
+ mimetype=mimetype,
574
+ start_time=start_time,
575
+ end_time=end_time,
576
+ loop=loop,
577
+ autoplay=autoplay,
578
+ muted=muted,
579
+ page=ctx.page_script_hash if ctx else None,
580
+ )
581
+
582
+ proto.id = id
583
+
534
584
 
535
585
  def _parse_start_time_end_time(
536
586
  start_time: MediaTime, end_time: MediaTime | None
@@ -647,6 +697,7 @@ def marshall_audio(
647
697
  sample_rate: int | None = None,
648
698
  end_time: int | None = None,
649
699
  loop: bool = False,
700
+ autoplay: bool = False,
650
701
  ) -> None:
651
702
  """Marshalls an audio proto, using data and url processors as needed.
652
703
 
@@ -670,6 +721,9 @@ def marshall_audio(
670
721
  The time at which this element should stop playing
671
722
  loop: bool
672
723
  Whether the audio should loop playback.
724
+ autoplay : bool
725
+ Whether the audio should start playing automatically.
726
+ Browsers will not autoplay audio files if the user has not interacted with the page yet.
673
727
  """
674
728
 
675
729
  proto.start_time = start_time
@@ -685,3 +739,19 @@ def marshall_audio(
685
739
  else:
686
740
  data = _maybe_convert_to_wav_bytes(data, sample_rate)
687
741
  _marshall_av_media(coordinates, proto, data, mimetype)
742
+
743
+ if autoplay:
744
+ ctx = get_script_run_ctx()
745
+ proto.autoplay = autoplay
746
+ id = compute_widget_id(
747
+ "audio",
748
+ url=proto.url,
749
+ mimetype=mimetype,
750
+ start_time=start_time,
751
+ sample_rate=sample_rate,
752
+ end_time=end_time,
753
+ loop=loop,
754
+ autoplay=autoplay,
755
+ page=ctx.page_script_hash if ctx else None,
756
+ )
757
+ proto.id = id
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
13
13
 
14
14
 
15
15
 
16
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Audio.proto\"h\n\x05\x41udio\x12\x0b\n\x03url\x18\x05 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x06 \x01(\x05\x12\x0c\n\x04loop\x18\x07 \x01(\x08J\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x04\x64\x61taR\x06\x66ormatB*\n\x1c\x63om.snowflake.apps.streamlitB\nAudioProtob\x06proto3')
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Audio.proto\"\x86\x01\n\x05\x41udio\x12\x0b\n\x03url\x18\x05 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x10\n\x08\x65nd_time\x18\x06 \x01(\x05\x12\x0c\n\x04loop\x18\x07 \x01(\x08\x12\x10\n\x08\x61utoplay\x18\x08 \x01(\x08\x12\n\n\x02id\x18\t \x01(\tJ\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x04\x64\x61taR\x06\x66ormatB*\n\x1c\x63om.snowflake.apps.streamlitB\nAudioProtob\x06proto3')
17
17
 
18
18
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
19
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.Audio_pb2', globals())
@@ -21,6 +21,6 @@ if _descriptor._USE_C_DESCRIPTORS == False:
21
21
 
22
22
  DESCRIPTOR._options = None
23
23
  DESCRIPTOR._serialized_options = b'\n\034com.snowflake.apps.streamlitB\nAudioProto'
24
- _AUDIO._serialized_start=31
25
- _AUDIO._serialized_end=135
24
+ _AUDIO._serialized_start=32
25
+ _AUDIO._serialized_end=166
26
26
  # @@protoc_insertion_point(module_scope)
@@ -35,6 +35,8 @@ class Audio(google.protobuf.message.Message):
35
35
  START_TIME_FIELD_NUMBER: builtins.int
36
36
  END_TIME_FIELD_NUMBER: builtins.int
37
37
  LOOP_FIELD_NUMBER: builtins.int
38
+ AUTOPLAY_FIELD_NUMBER: builtins.int
39
+ ID_FIELD_NUMBER: builtins.int
38
40
  url: builtins.str
39
41
  start_time: builtins.int
40
42
  """The currentTime attribute of the HTML <audio> tag's <source> subtag."""
@@ -42,6 +44,8 @@ class Audio(google.protobuf.message.Message):
42
44
  """The time at which the audio should stop playing. If not specified, plays to the end."""
43
45
  loop: builtins.bool
44
46
  """Indicates whether the audio should start over from the beginning once it ends."""
47
+ autoplay: builtins.bool
48
+ id: builtins.str
45
49
  def __init__(
46
50
  self,
47
51
  *,
@@ -49,7 +53,9 @@ class Audio(google.protobuf.message.Message):
49
53
  start_time: builtins.int = ...,
50
54
  end_time: builtins.int = ...,
51
55
  loop: builtins.bool = ...,
56
+ autoplay: builtins.bool = ...,
57
+ id: builtins.str = ...,
52
58
  ) -> None: ...
53
- def ClearField(self, field_name: typing_extensions.Literal["end_time", b"end_time", "loop", b"loop", "start_time", b"start_time", "url", b"url"]) -> None: ...
59
+ def ClearField(self, field_name: typing_extensions.Literal["autoplay", b"autoplay", "end_time", b"end_time", "id", b"id", "loop", b"loop", "start_time", b"start_time", "url", b"url"]) -> None: ...
54
60
 
55
61
  global___Audio = Audio
@@ -13,7 +13,7 @@ _sym_db = _symbol_database.Default()
13
13
 
14
14
 
15
15
 
16
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Video.proto\"+\n\rSubtitleTrack\x12\r\n\x05label\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\"\xda\x01\n\x05Video\x12\x0b\n\x03url\x18\x06 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x19\n\x04type\x18\x05 \x01(\x0e\x32\x0b.Video.Type\x12!\n\tsubtitles\x18\x07 \x03(\x0b\x32\x0e.SubtitleTrack\x12\x10\n\x08\x65nd_time\x18\x08 \x01(\x05\x12\x0c\n\x04loop\x18\t \x01(\x08\"2\n\x04Type\x12\n\n\x06UNUSED\x10\x00\x12\n\n\x06NATIVE\x10\x01\x12\x12\n\x0eYOUTUBE_IFRAME\x10\x02J\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x06\x66ormatR\x04\x64\x61taB*\n\x1c\x63om.snowflake.apps.streamlitB\nVideoProtob\x06proto3')
16
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x1bstreamlit/proto/Video.proto\"+\n\rSubtitleTrack\x12\r\n\x05label\x18\x01 \x01(\t\x12\x0b\n\x03url\x18\x02 \x01(\t\"\x87\x02\n\x05Video\x12\x0b\n\x03url\x18\x06 \x01(\t\x12\x12\n\nstart_time\x18\x03 \x01(\x05\x12\x19\n\x04type\x18\x05 \x01(\x0e\x32\x0b.Video.Type\x12!\n\tsubtitles\x18\x07 \x03(\x0b\x32\x0e.SubtitleTrack\x12\x10\n\x08\x65nd_time\x18\x08 \x01(\x05\x12\x0c\n\x04loop\x18\t \x01(\x08\x12\x10\n\x08\x61utoplay\x18\n \x01(\x08\x12\r\n\x05muted\x18\x0b \x01(\x08\x12\n\n\x02id\x18\x0c \x01(\t\"2\n\x04Type\x12\n\n\x06UNUSED\x10\x00\x12\n\n\x06NATIVE\x10\x01\x12\x12\n\x0eYOUTUBE_IFRAME\x10\x02J\x04\x08\x01\x10\x02J\x04\x08\x02\x10\x03J\x04\x08\x04\x10\x05R\x06\x66ormatR\x04\x64\x61taB*\n\x1c\x63om.snowflake.apps.streamlitB\nVideoProtob\x06proto3')
17
17
 
18
18
  _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, globals())
19
19
  _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'streamlit.proto.Video_pb2', globals())
@@ -24,7 +24,7 @@ if _descriptor._USE_C_DESCRIPTORS == False:
24
24
  _SUBTITLETRACK._serialized_start=31
25
25
  _SUBTITLETRACK._serialized_end=74
26
26
  _VIDEO._serialized_start=77
27
- _VIDEO._serialized_end=295
28
- _VIDEO_TYPE._serialized_start=213
29
- _VIDEO_TYPE._serialized_end=263
27
+ _VIDEO._serialized_end=340
28
+ _VIDEO_TYPE._serialized_start=258
29
+ _VIDEO_TYPE._serialized_end=308
30
30
  # @@protoc_insertion_point(module_scope)
@@ -76,6 +76,9 @@ class Video(google.protobuf.message.Message):
76
76
  SUBTITLES_FIELD_NUMBER: builtins.int
77
77
  END_TIME_FIELD_NUMBER: builtins.int
78
78
  LOOP_FIELD_NUMBER: builtins.int
79
+ AUTOPLAY_FIELD_NUMBER: builtins.int
80
+ MUTED_FIELD_NUMBER: builtins.int
81
+ ID_FIELD_NUMBER: builtins.int
79
82
  url: builtins.str
80
83
  """A url pointing to a video file"""
81
84
  start_time: builtins.int
@@ -89,6 +92,9 @@ class Video(google.protobuf.message.Message):
89
92
  """The time at which the video should stop playing. If not specified, plays to the end."""
90
93
  loop: builtins.bool
91
94
  """Indicates whether the video should start over from the beginning once it ends."""
95
+ autoplay: builtins.bool
96
+ muted: builtins.bool
97
+ id: builtins.str
92
98
  def __init__(
93
99
  self,
94
100
  *,
@@ -98,7 +104,10 @@ class Video(google.protobuf.message.Message):
98
104
  subtitles: collections.abc.Iterable[global___SubtitleTrack] | None = ...,
99
105
  end_time: builtins.int = ...,
100
106
  loop: builtins.bool = ...,
107
+ autoplay: builtins.bool = ...,
108
+ muted: builtins.bool = ...,
109
+ id: builtins.str = ...,
101
110
  ) -> None: ...
102
- def ClearField(self, field_name: typing_extensions.Literal["end_time", b"end_time", "loop", b"loop", "start_time", b"start_time", "subtitles", b"subtitles", "type", b"type", "url", b"url"]) -> None: ...
111
+ def ClearField(self, field_name: typing_extensions.Literal["autoplay", b"autoplay", "end_time", b"end_time", "id", b"id", "loop", b"loop", "muted", b"muted", "start_time", b"start_time", "subtitles", b"subtitles", "type", b"type", "url", b"url"]) -> None: ...
103
112
 
104
113
  global___Video = Video
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.bf304093.css",
4
- "main.js": "./static/js/main.8fc4565f.js",
4
+ "main.js": "./static/js/main.d3201242.js",
5
5
  "static/js/9336.2d95d840.chunk.js": "./static/js/9336.2d95d840.chunk.js",
6
- "static/js/9330.d29313d4.chunk.js": "./static/js/9330.d29313d4.chunk.js",
6
+ "static/js/9330.2b4c99e0.chunk.js": "./static/js/9330.2b4c99e0.chunk.js",
7
7
  "static/js/7217.d970c074.chunk.js": "./static/js/7217.d970c074.chunk.js",
8
8
  "static/js/3301.1d1b10bb.chunk.js": "./static/js/3301.1d1b10bb.chunk.js",
9
9
  "static/css/3092.95a45cfe.chunk.css": "./static/css/3092.95a45cfe.chunk.css",
@@ -19,7 +19,7 @@
19
19
  "static/js/2469.3e9c3ce9.chunk.js": "./static/js/2469.3e9c3ce9.chunk.js",
20
20
  "static/js/4113.1e7eff4d.chunk.js": "./static/js/4113.1e7eff4d.chunk.js",
21
21
  "static/js/1168.1d6408e6.chunk.js": "./static/js/1168.1d6408e6.chunk.js",
22
- "static/js/178.b5384fd0.chunk.js": "./static/js/178.b5384fd0.chunk.js",
22
+ "static/js/178.7bea8c5d.chunk.js": "./static/js/178.7bea8c5d.chunk.js",
23
23
  "static/js/1792.b8efa879.chunk.js": "./static/js/1792.b8efa879.chunk.js",
24
24
  "static/js/3513.e3e7300a.chunk.js": "./static/js/3513.e3e7300a.chunk.js",
25
25
  "static/js/7602.6175e969.chunk.js": "./static/js/7602.6175e969.chunk.js",
@@ -152,6 +152,6 @@
152
152
  },
153
153
  "entrypoints": [
154
154
  "static/css/main.bf304093.css",
155
- "static/js/main.8fc4565f.js"
155
+ "static/js/main.d3201242.js"
156
156
  ]
157
157
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.8fc4565f.js"></script><link href="./static/css/main.bf304093.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.d3201242.js"></script><link href="./static/css/main.bf304093.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[178],{178:(e,t,r)=>{r.r(t),r.d(t,{default:()=>l});var a=r(66845),n=r(16295),s=r(68785),i=r(40864);const d=528;function l(e){let{element:t,width:r,endpoints:l,elementMgr:o}=e;const u=(0,a.useRef)(null),{type:c,url:p,startTime:m,subtitles:f,endTime:h,loop:v,autoplay:y,muted:E}=t,T=(0,a.useMemo)((()=>{if(!t.id)return!0;const e=o.getElementState(t.id,"preventAutoplay");return e||o.setElementState(t.id,"preventAutoplay",!0),null!==e&&void 0!==e&&e}),[t.id,o]);(0,a.useEffect)((()=>{u.current&&(u.current.currentTime=m)}),[m]),(0,a.useEffect)((()=>{const e=u.current,r=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",r),()=>{e&&e.removeEventListener("loadedmetadata",r)}}),[t]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;let t=!1;const r=()=>{h>0&&e.currentTime>=h&&(v?(e.currentTime=m||0,e.play()):t||(t=!0,e.pause()))};return h>0&&e.addEventListener("timeupdate",r),()=>{e&&h>0&&e.removeEventListener("timeupdate",r)}}),[h,v,m]),(0,a.useEffect)((()=>{const e=u.current;if(!e)return;const t=()=>{v&&(e.currentTime=m||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[v,m]);const g=e=>{const{startTime:r,endTime:a,loop:n,autoplay:s,muted:i}=t,d=new URL(e);if(r&&!isNaN(r)&&d.searchParams.append("start",r.toString()),a&&!isNaN(a)&&d.searchParams.append("end",a.toString()),n){d.searchParams.append("loop","1");const e=d.pathname.split("/").pop();e&&d.searchParams.append("playlist",e)}return s&&d.searchParams.append("autoplay","1"),i&&d.searchParams.append("mute","1"),d.toString()};if(c===n.nk.Type.YOUTUBE_IFRAME){const e=0!==r?.75*r:d;return(0,i.jsx)("iframe",{"data-testid":"stVideo",title:p,src:g(p),width:r,height:e,style:{colorScheme:"normal"},frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,i.jsx)("video",{"data-testid":"stVideo",ref:u,controls:!0,muted:E,autoPlay:y&&!T,src:l.buildMediaURL(p),className:"stVideo",style:{width:r,height:0===r?d:void 0},crossOrigin:s.td&&f.length>0?"anonymous":void 0,children:f&&f.map(((e,t)=>(0,i.jsx)("track",{kind:"captions",src:l.buildMediaURL(e.url),label:e.label,default:0===t},t)))})}}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_streamlit_app=self.webpackChunk_streamlit_app||[]).push([[9330],{69330:(e,t,r)=>{r.r(t),r.d(t,{default:()=>a});var n=r(66845),u=r(40864);function a(e){let{element:t,width:r,endpoints:a,elementMgr:s}=e;const i=(0,n.useRef)(null),{startTime:d,endTime:c,loop:l,autoplay:o}=t,m=(0,n.useMemo)((()=>{if(!t.id)return!0;const e=s.getElementState(t.id,"preventAutoplay");return e||s.setElementState(t.id,"preventAutoplay",!0),null!==e&&void 0!==e&&e}),[t.id,s]);(0,n.useEffect)((()=>{i.current&&(i.current.currentTime=d)}),[d]),(0,n.useEffect)((()=>{const e=i.current,r=()=>{e&&(e.currentTime=t.startTime)};return e&&e.addEventListener("loadedmetadata",r),()=>{e&&e.removeEventListener("loadedmetadata",r)}}),[t]),(0,n.useEffect)((()=>{const e=i.current;if(!e)return;let t=!1;const r=()=>{c>0&&e.currentTime>=c&&(l?(e.currentTime=d||0,e.play()):t||(t=!0,e.pause()))};return c>0&&e.addEventListener("timeupdate",r),()=>{e&&c>0&&e.removeEventListener("timeupdate",r)}}),[c,l,d]),(0,n.useEffect)((()=>{const e=i.current;if(!e)return;const t=()=>{l&&(e.currentTime=d||0,e.play())};return e.addEventListener("ended",t),()=>{e&&e.removeEventListener("ended",t)}}),[l,d]);const p=a.buildMediaURL(t.url);return(0,u.jsx)("audio",{"data-testid":"stAudio",id:"audio",ref:i,controls:!0,autoPlay:o&&!m,src:p,className:"stAudio",style:{width:r}})}}}]);