Skip to content

Commit df5e974

Browse files
kmeisthaxHerschel
authored andcommitted
core: Adjust documentation
1 parent 5e9d917 commit df5e974

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

core/src/display_object/video.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ impl<'gc> Video<'gc> {
149149
}
150150

151151
/// Seek to a particular frame in the video stream.
152+
///
153+
/// This function ensures that the given `frame_id` is valid by first
154+
/// wrapping it to the underlying video stream's boundaries, and then
155+
/// snapping it to the last independently seekable frame. Then, all frames
156+
/// from that keyframe up to the (wrapped) requested frame are decoded in
157+
/// order. This matches Flash Player behavior.
152158
pub fn seek(self, context: &mut UpdateContext<'_, 'gc, '_>, mut frame_id: u32) {
153159
let read = self.0.read();
154160
if let VideoStream::Uninstantiated(_) = &read.stream {
@@ -208,20 +214,25 @@ impl<'gc> Video<'gc> {
208214
drop(read);
209215

210216
for fr in sweep_from..=frame_id {
211-
self.do_seek(context, fr)
217+
self.seek_internal(context, fr)
212218
}
213219
}
214220

215-
/// The internals of `seek` factored out, separate from the sweeping mechanism.
216-
fn do_seek(self, context: &mut UpdateContext<'_, 'gc, '_>, frame_id: u32) {
221+
/// Decode a single frame of video.
222+
///
223+
/// This function makes no attempt to ensure that the proposed seek is
224+
/// valid, hence the fact that it's not `pub`. To do a seek that accounts
225+
/// for keyframes, see `Video.seek`.
226+
fn seek_internal(self, context: &mut UpdateContext<'_, 'gc, '_>, frame_id: u32) {
217227
let read = self.0.read();
218228
let source = read.source;
219229
let stream = if let VideoStream::Instantiated(stream) = &read.stream {
220230
stream
221231
} else {
222-
log::error!("Attempted to sync uninstantiated video stream!");
232+
log::error!("Attempted to seek uninstantiated video stream.");
223233
return;
224234
};
235+
225236
let res = match &*source.read() {
226237
VideoSource::Swf {
227238
movie,

0 commit comments

Comments
 (0)