UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IMediaPlayer.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
6#include "Containers/Array.h"
7#include "Containers/Map.h"
9#include "Math/Interval.h"
10#include "Math/IntPoint.h"
11#include "Math/MathFwd.h"
12#include "Misc/Paths.h"
13#include "Misc/Timespan.h"
14#include "Misc/Variant.h"
15
16class FArchive;
17
18class IMediaCache;
19class IMediaControls;
20class IMediaOptions;
21class IMediaSamples;
22class IMediaTracks;
23class IMediaView;
25
26struct FGuid;
28
35{
36public:
37
38 //~ The following methods must be implemented by media players
39
53 virtual void Close() = 0;
54
63 virtual IMediaCache& GetCache() = 0;
64
74
81 virtual FString GetInfo() const = 0;
82
89 virtual FGuid GetPlayerPluginGUID() const = 0;
90
99 virtual IMediaSamples& GetSamples() = 0;
100
107 virtual FString GetStats() const = 0;
108
117 virtual IMediaTracks& GetTracks() = 0;
118
124 virtual FString GetUrl() const = 0;
125
134 virtual IMediaView& GetView() = 0;
135
153 virtual bool Open(const FString& Url, const IMediaOptions* Options) = 0;
154
173 virtual bool Open(const TSharedRef<FArchive, ESPMode::ThreadSafe>& Archive, const FString& OriginalUrl, const IMediaOptions* Options) = 0;
174
175public:
176
177 //~ The following methods are optional
178
183 virtual bool Open(const FString& Url, const IMediaOptions* Options, const FMediaPlayerOptions* PlayerOptions)
184 {
185 return Open(Url, Options);
186 }
187
196 {
197 return FVariant();
198 }
199
216
228 virtual FText GetMediaName() const
229 {
230 const FString Url = GetUrl();
231
232 if (Url.IsEmpty())
233 {
234 return FText::GetEmpty();
235 }
236
238 }
239
245 virtual void SetGuid(const FGuid& Guid)
246 {
247 // override in child classes if supported
248 }
249
256 virtual bool SetNativeVolume(float Volume)
257 {
258 return false;
259 }
260
267 {
268 // override in child classes if supported
269 }
270
279 virtual void TickAudio()
280 {
281 // override in child class if needed
282 }
283
294 virtual void TickFetch(FTimespan DeltaTime, FTimespan Timecode)
295 {
296 // override in child class if needed
297 }
298
309 virtual void TickInput(FTimespan DeltaTime, FTimespan Timecode)
310 {
311 // override in child class if needed
312 }
313
319 virtual bool FlushOnSeekStarted() const
320 {
321 return false;
322 }
323
329 virtual bool FlushOnSeekCompleted() const
330 {
331 return true;
332 }
333
344
345 virtual bool GetPlayerFeatureFlag(EFeatureFlag /*flag*/) const
346 {
347 // Override in child class if needed.
348 return false;
349 }
350
352 {
353 public:
355 virtual void Signal(uint32 ResourceFlags) = 0;
356 };
358
363 {
364 // Override in child class if needed.
365 return false;
366 }
367
368 /*
369 * Return IMediaPlayerLifecycleManagerDelegate::ResourceFlags bitmask to indicate resource types recreated on a open call
370 */
372 {
373 // Override in child class if needed. Default assumes resources carry over (to a large degree) and are created per instance only
374 // (as a simplified model for older players)
375 return 0;
376 }
377
378public:
379
381 virtual ~IMediaPlayer() { }
382};
int Volume
Definition AndroidPlatformMisc.cpp:380
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition NameTypes.h:617
static CORE_API FString GetBaseFilename(const FString &InPath, bool bRemovePath=true)
Definition Paths.cpp:1033
Definition Text.h:385
static CORE_API FText FromString(const ANSICHAR *String)
Definition Text.cpp:1081
static CORE_API const FText & GetEmpty()
Definition Text.cpp:252
Definition Variant.h:114
Definition IMediaCache.h:37
Definition IMediaControls.h:142
Definition IMediaMetadataItem.h:12
Definition IMediaOptions.h:15
virtual void Signal(uint32 ResourceFlags)=0
virtual ~IAsyncResourceReleaseNotification()
Definition IMediaPlayer.h:354
Definition IMediaPlayer.h:35
virtual bool FlushOnSeekStarted() const
Definition IMediaPlayer.h:319
virtual ~IMediaPlayer()
Definition IMediaPlayer.h:381
EFeatureFlag
Definition IMediaPlayer.h:335
@ PlayerUsesInternalFlushOnSeek
The player implements an internal flush logic on seeks and Mediaframework will not issue an explicit ...
@ AllowShutdownOnClose
Allow player to be shutdown right after 'close' event is received from it.
@ IsTrackSwitchSeamless
If track switching is seamless then a flush of sinks is not necessary.
@ PlayerSelectsDefaultTracks
Whether or not the player selects suitable track defaults.
@ UseRealtimeWithVideoOnly
Use realtime rather then game deltatime to control video playback if no audio is present.
@ AlwaysPullNewestVideoFrame
Mediaframework will not gate video frame output with its own timing, but assumes "ASAP" as output tim...
@ UsePlaybackTimingV2
Use v2 playback timing and AV sync.
virtual bool Open(const TSharedRef< FArchive, ESPMode::ThreadSafe > &Archive, const FString &OriginalUrl, const IMediaOptions *Options)=0
TSharedRef< IAsyncResourceReleaseNotification, ESPMode::ThreadSafe > IAsyncResourceReleaseNotificationRef
Definition IMediaPlayer.h:357
virtual IMediaTracks & GetTracks()=0
virtual FGuid GetPlayerPluginGUID() const =0
virtual void TickAudio()
Definition IMediaPlayer.h:279
virtual bool SetNativeVolume(float Volume)
Definition IMediaPlayer.h:256
virtual void TickInput(FTimespan DeltaTime, FTimespan Timecode)
Definition IMediaPlayer.h:309
virtual bool Open(const FString &Url, const IMediaOptions *Options, const FMediaPlayerOptions *PlayerOptions)
Definition IMediaPlayer.h:183
virtual void SetLastAudioRenderedSampleTime(FTimespan SampleTime)
Definition IMediaPlayer.h:266
virtual uint32 GetNewResourcesOnOpen() const
Definition IMediaPlayer.h:371
virtual bool GetPlayerFeatureFlag(EFeatureFlag) const
Definition IMediaPlayer.h:345
virtual IMediaControls & GetControls()=0
virtual FString GetInfo() const =0
virtual void SetGuid(const FGuid &Guid)
Definition IMediaPlayer.h:245
virtual TSharedPtr< TMap< FString, TArray< TUniquePtr< IMediaMetadataItem > > >, ESPMode::ThreadSafe > GetMediaMetadata() const
Definition IMediaPlayer.h:212
virtual IMediaCache & GetCache()=0
virtual FText GetMediaName() const
Definition IMediaPlayer.h:228
virtual FVariant GetMediaInfo(FName InfoName) const
Definition IMediaPlayer.h:195
virtual bool FlushOnSeekCompleted() const
Definition IMediaPlayer.h:329
virtual FString GetUrl() const =0
virtual void TickFetch(FTimespan DeltaTime, FTimespan Timecode)
Definition IMediaPlayer.h:294
virtual IMediaView & GetView()=0
virtual void Close()=0
virtual FString GetStats() const =0
virtual IMediaSamples & GetSamples()=0
virtual bool SetAsyncResourceReleaseNotification(IAsyncResourceReleaseNotificationRef AsyncDestructNotification)
Definition IMediaPlayer.h:362
virtual bool Open(const FString &Url, const IMediaOptions *Options)=0
Definition IMediaSamples.h:24
Definition IMediaTracks.h:88
Definition IMediaView.h:90
Definition SharedPointer.h:692
Definition SharedPointer.h:153
Definition Guid.h:109
Definition MediaPlayerOptions.h:125
Definition Timespan.h:76