| 386 | } |
| 387 | |
| 388 | void UpdatePlayer(int32 index) |
| 389 | { |
| 390 | PROFILE_CPU(); |
| 391 | PROFILE_MEM(Video); |
| 392 | auto& player = *Players[index]; |
| 393 | ZoneText(player.DebugUrl, player.DebugUrlLen); |
| 394 | auto& playerMF = player.GetBackendState<VideoPlayerMF>(); |
| 395 | |
| 396 | // Skip paused player |
| 397 | if (!playerMF.Playing && !playerMF.Seek) |
| 398 | return; |
| 399 | |
| 400 | // Update playback time |
| 401 | if (playerMF.FirstFrame) |
| 402 | { |
| 403 | playerMF.FirstFrame = 0; |
| 404 | playerMF.Seek = 1; |
| 405 | } |
| 406 | else if (playerMF.Playing) |
| 407 | { |
| 408 | playerMF.Time += UpdateDeltaTime; |
| 409 | } |
| 410 | if (playerMF.Time > player.Duration && player.Duration.Ticks != 0) |
| 411 | { |
| 412 | if (playerMF.Loop) |
| 413 | { |
| 414 | // Loop |
| 415 | playerMF.Time.Ticks %= player.Duration.Ticks; |
| 416 | playerMF.Seek = 1; |
| 417 | player.PlayAudio(); |
| 418 | } |
| 419 | else |
| 420 | { |
| 421 | // End |
| 422 | playerMF.Time = player.Duration; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | // Update current position |
| 427 | bool canSeek = true; |
| 428 | SEEK_START: |
| 429 | if (playerMF.Seek) |
| 430 | { |
| 431 | // Reset cached frames timings |
| 432 | player.VideoFrameDuration = player.AudioBufferDuration = TimeSpan::Zero(); |
| 433 | |
| 434 | playerMF.Seek = 0; |
| 435 | PROPVARIANT var; |
| 436 | PropVariantInit(&var); |
| 437 | var.vt = VT_I8; |
| 438 | var.hVal.QuadPart = playerMF.Time.Ticks; |
| 439 | PROFILE_CPU_NAMED("SetCurrentPosition"); |
| 440 | playerMF.SourceReader->SetCurrentPosition(GUID_NULL, var); |
| 441 | |
| 442 | // Note: |
| 443 | // SetCurrentPosition method does not guarantee exact seeking. |
| 444 | // The accuracy of the seek depends on the media content. |
| 445 | // If the media content contains a video stream, the SetCurrentPosition method typically seeks to the nearest key frame before the desired position. |
nothing calls this directly
no test coverage detected