Add OnPreparing method to initialize callbacks, etc.
Change-Id: Iceb332a1d621d066055be0480051b773654855be
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
Name: csapi-multimedia
Summary: Tizen Multimedia API for C#
-Version: 1.0.51
+Version: 1.0.52
Release: 0
Group: Development/Libraries
License: Apache-2.0
internal delegate void PlaybackCompletedCallback(IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PlaybackInterruptedCallback(int code, IntPtr userData);
+ internal delegate void PlaybackInterruptedCallback(PlaybackInterruptionReason code, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void PlaybackErrorCallback(int code, IntPtr userData);
internal delegate void VideoStreamChangedCallback(int width, int height, int fps, int bitrate, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void MediaStreamBufferStatusCallback(int status, IntPtr userData);
+ internal delegate void MediaStreamBufferStatusCallback(MediaStreamBufferStatus status, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void MediaStreamSeekCallback(ulong offset, IntPtr userData);
[DllImport(Libraries.Player, EntryPoint = "player_create")]
- internal static extern int Create(out IntPtr player);
+ internal static extern PlayerErrorCode Create(out PlayerHandle player);
[DllImport(Libraries.Player, EntryPoint = "player_destroy")]
- internal static extern int Destroy(IntPtr player);
+ internal static extern PlayerErrorCode Destroy(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_prepare")]
- internal static extern int Prepare(IntPtr player);
-
- [DllImport(Libraries.Player, EntryPoint = "player_prepare_async")]
- internal static extern int PrepareAsync(IntPtr player, PrepareCallback cb, IntPtr userData);
+ internal static extern PlayerErrorCode Prepare(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_unprepare")]
- internal static extern int Unprepare(IntPtr player);
+ internal static extern PlayerErrorCode Unprepare(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_uri")]
- internal static extern int SetUri(IntPtr player, string uri);
+ internal static extern PlayerErrorCode SetUri(IntPtr player, string uri);
[DllImport(Libraries.Player, EntryPoint = "player_set_display")]
- internal static extern int SetDisplay(IntPtr player, PlayerDisplayType type, IntPtr display);
+ internal static extern PlayerErrorCode SetDisplay(IntPtr player, PlayerDisplayType type, IntPtr display);
[DllImport(Libraries.Player, EntryPoint = "player_start")]
- internal static extern int Start(IntPtr player);
+ internal static extern PlayerErrorCode Start(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_stop")]
- internal static extern int Stop(IntPtr player);
+ internal static extern PlayerErrorCode Stop(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_pause")]
- internal static extern int Pause(IntPtr player);
+ internal static extern PlayerErrorCode Pause(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_memory_buffer")]
- internal static extern int SetMemoryBuffer(IntPtr player, byte[] data, int size);
+ internal static extern PlayerErrorCode SetMemoryBuffer(IntPtr player, byte[] data, int size);
[DllImport(Libraries.Player, EntryPoint = "player_get_state")]
- internal static extern int GetState(IntPtr player, out int state);
+ internal static extern PlayerErrorCode GetState(IntPtr player, out int state);
[DllImport(Libraries.Player, EntryPoint = "player_set_volume")]
- internal static extern int SetVolume(IntPtr player, float left, float right);
+ internal static extern PlayerErrorCode SetVolume(IntPtr player, float left, float right);
[DllImport(Libraries.Player, EntryPoint = "player_get_volume")]
- internal static extern int GetVolume(IntPtr player, out float left, out float right);
+ internal static extern PlayerErrorCode GetVolume(IntPtr player, out float left, out float right);
[DllImport(Libraries.Player, EntryPoint = "player_set_sound_stream_info")]
- internal static extern int SetAudioPolicyInfo(IntPtr player, IntPtr streamInfo);
+ internal static extern PlayerErrorCode SetAudioPolicyInfo(IntPtr player, IntPtr streamInfo);
[DllImport(Libraries.Player, EntryPoint = "player_set_audio_latency_mode")]
- internal static extern int SetAudioLatencyMode(IntPtr player, int latencyMode);
+ internal static extern PlayerErrorCode SetAudioLatencyMode(IntPtr player, AudioLatencyMode latencyMode);
[DllImport(Libraries.Player, EntryPoint = "player_get_audio_latency_mode")]
- internal static extern int GetAudioLatencyMode(IntPtr player, out int latencyMode);
+ internal static extern PlayerErrorCode GetAudioLatencyMode(IntPtr player, out AudioLatencyMode latencyMode);
[DllImport(Libraries.Player, EntryPoint = "player_get_play_position")]
- internal static extern int GetPlayPosition(IntPtr player, out int millisecond);
+ internal static extern PlayerErrorCode GetPlayPosition(IntPtr player, out int millisecond);
[DllImport(Libraries.Player, EntryPoint = "player_set_play_position")]
- internal static extern int SetPlayPosition(IntPtr player, int millisecond, bool accurate, SeekCompletedCallback cb, IntPtr userData);
+ internal static extern PlayerErrorCode SetPlayPosition(IntPtr player, int millisecond,
+ bool accurate, SeekCompletedCallback cb, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_set_mute")]
- internal static extern int SetMute(IntPtr player, bool muted);
+ internal static extern PlayerErrorCode SetMute(IntPtr player, bool muted);
[DllImport(Libraries.Player, EntryPoint = "player_is_muted")]
- internal static extern int IsMuted(IntPtr player, out bool muted);
+ internal static extern PlayerErrorCode IsMuted(IntPtr player, out bool muted);
[DllImport(Libraries.Player, EntryPoint = "player_set_looping")]
- internal static extern int SetLooping(IntPtr player, bool looping);
+ internal static extern PlayerErrorCode SetLooping(IntPtr player, bool looping);
[DllImport(Libraries.Player, EntryPoint = "player_is_looping")]
- internal static extern int IsLooping(IntPtr player, out bool looping);
+ internal static extern PlayerErrorCode IsLooping(IntPtr player, out bool looping);
[DllImport(Libraries.Player, EntryPoint = "player_set_completed_cb")]
- internal static extern int SetCompletedCb(IntPtr player, PlaybackCompletedCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetCompletedCb(IntPtr player,
+ PlaybackCompletedCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_completed_cb")]
- internal static extern int UnsetCompletedCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetCompletedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_interrupted_cb")]
- internal static extern int SetInterruptedCb(IntPtr player, PlaybackInterruptedCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetInterruptedCb(IntPtr player,
+ PlaybackInterruptedCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_interrupted_cb")]
- internal static extern int UnsetInterruptedCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetInterruptedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_error_cb")]
- internal static extern int SetErrorCb(IntPtr player, PlaybackErrorCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetErrorCb(IntPtr player, PlaybackErrorCallback callback,
+ IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_error_cb")]
- internal static extern int UnsetErrorCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetErrorCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_capture_video")]
- internal static extern int CaptureVideo(IntPtr player, VideoCaptureCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode CaptureVideo(IntPtr player, VideoCaptureCallback callback,
+ IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_set_media_packet_video_frame_decoded_cb")]
- internal static extern int SetVideoFrameDecodedCb(IntPtr player, VideoFrameDecodedCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetVideoFrameDecodedCb(IntPtr player, VideoFrameDecodedCallback callback,
+ IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_packet_video_frame_decoded_cb")]
- internal static extern int UnsetVideoFrameDecodedCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetVideoFrameDecodedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_streaming_cookie")]
- internal static extern int SetStreamingCookie(IntPtr player, string cookie, int size);
+ internal static extern PlayerErrorCode SetStreamingCookie(IntPtr player, string cookie, int size);
[DllImport(Libraries.Player, EntryPoint = "player_set_streaming_user_agent")]
- internal static extern int SetStreamingUserAgent(IntPtr player, string userAgent, int size);
+ internal static extern PlayerErrorCode SetStreamingUserAgent(IntPtr player, string userAgent, int size);
[DllImport(Libraries.Player, EntryPoint = "player_get_streaming_download_progress")]
- internal static extern int GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
+ internal static extern PlayerErrorCode GetStreamingDownloadProgress(IntPtr player, out int start, out int current);
[DllImport(Libraries.Player, EntryPoint = "player_set_buffering_cb")]
- internal static extern int SetBufferingCb(IntPtr player, BufferingProgressCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetBufferingCb(IntPtr player,
+ BufferingProgressCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_buffering_cb")]
- internal static extern int UnsetBufferingCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetBufferingCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_playback_rate")]
- internal static extern int SetPlaybackRate(IntPtr player, float rate);
+ internal static extern PlayerErrorCode SetPlaybackRate(IntPtr player, float rate);
[DllImport(Libraries.Player, EntryPoint = "player_push_media_stream")]
- internal static extern int PushMediaStream(IntPtr player, IntPtr packet);
+ internal static extern PlayerErrorCode PushMediaStream(IntPtr player, IntPtr packet);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_info")]
- internal static extern int SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
+ internal static extern PlayerErrorCode SetMediaStreamInfo(IntPtr player, int type, IntPtr format);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_status_cb")]
- internal static extern int SetMediaStreamBufferStatusCb(IntPtr player, int type, MediaStreamBufferStatusCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetMediaStreamBufferStatusCb(IntPtr player, StreamType type,
+ MediaStreamBufferStatusCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_buffer_status_cb")]
- internal static extern int UnsetMediaStreamBufferStatusCb(IntPtr player, int type);
+ internal static extern PlayerErrorCode UnsetMediaStreamBufferStatusCb(IntPtr player, int type);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_seek_cb")]
- internal static extern int SetMediaStreamSeekCb(IntPtr player, int type, MediaStreamSeekCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetMediaStreamSeekCb(IntPtr player, StreamType type,
+ MediaStreamSeekCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_media_stream_seek_cb")]
- internal static extern int UnsetMediaStreamSeekCb(IntPtr player, int type);
+ internal static extern PlayerErrorCode UnsetMediaStreamSeekCb(IntPtr player, int type);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_max_size")]
- internal static extern int SetMediaStreamBufferMaxSize(IntPtr player, int type, ulong maxSize);
+ internal static extern PlayerErrorCode SetMediaStreamBufferMaxSize(IntPtr player, StreamType type, ulong maxSize);
[DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_max_size")]
- internal static extern int GetMediaStreamBufferMaxSize(IntPtr player, int type, out ulong maxSize);
+ internal static extern PlayerErrorCode GetMediaStreamBufferMaxSize(IntPtr player, StreamType type, out ulong maxSize);
[DllImport(Libraries.Player, EntryPoint = "player_set_media_stream_buffer_min_threshold")]
- internal static extern int SetMediaStreamBufferMinThreshold(IntPtr player, int type, uint percent);
+ internal static extern PlayerErrorCode SetMediaStreamBufferMinThreshold(IntPtr player, StreamType type, uint percent);
[DllImport(Libraries.Player, EntryPoint = "player_get_media_stream_buffer_min_threshold")]
- internal static extern int GetMediaStreamBufferMinThreshold(IntPtr player, int type, out uint percent);
+ internal static extern PlayerErrorCode GetMediaStreamBufferMinThreshold(IntPtr player, int type, out uint percent);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_bands_count")]
- internal static extern int AudioEffectGetEqualizerBandsCount(IntPtr player, out int count);
+ internal static extern PlayerErrorCode AudioEffectGetEqualizerBandsCount(IntPtr player, out int count);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_band_level")]
- internal static extern int AudioEffectSetEqualizerBandLevel(IntPtr player, int index, int level);
+ internal static extern PlayerErrorCode AudioEffectSetEqualizerBandLevel(IntPtr player, int index, int level);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_level")]
- internal static extern int AudioEffectGetEqualizerBandLevel(IntPtr player, int index, out int level);
+ internal static extern PlayerErrorCode AudioEffectGetEqualizerBandLevel(IntPtr player, int index, out int level);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_set_equalizer_all_bands")]
- internal static extern int AudioEffectSetEqualizerAllBands(IntPtr player, out int band_levels, int length);
+ internal static extern PlayerErrorCode AudioEffectSetEqualizerAllBands(IntPtr player, out int band_levels, int length);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_level_range")]
- internal static extern int AudioEffectGetEqualizerLevelRange(IntPtr player, out int min, out int max);
+ internal static extern PlayerErrorCode AudioEffectGetEqualizerLevelRange(IntPtr player, out int min, out int max);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency")]
- internal static extern int AudioEffectGetEqualizerBandFrequency(IntPtr player, int index, out int frequency);
+ internal static extern PlayerErrorCode AudioEffectGetEqualizerBandFrequency(IntPtr player, int index, out int frequency);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_get_equalizer_band_frequency_range")]
- internal static extern int AudioEffectGetEqualizerBandFrequencyRange(IntPtr player, int index, out int range);
+ internal static extern PlayerErrorCode AudioEffectGetEqualizerBandFrequencyRange(IntPtr player, int index, out int range);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_clear")]
- internal static extern int AudioEffectEqualizerClear(IntPtr player);
+ internal static extern PlayerErrorCode AudioEffectEqualizerClear(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_audio_effect_equalizer_is_available")]
- internal static extern int AudioEffectEqualizerIsAvailable(IntPtr player, out bool available);
+ internal static extern PlayerErrorCode AudioEffectEqualizerIsAvailable(IntPtr player, out bool available);
[DllImport(Libraries.Player, EntryPoint = "player_set_display_mode")]
- internal static extern int SetDisplayMode(IntPtr player, int mode);
+ internal static extern PlayerErrorCode SetDisplayMode(IntPtr player, PlayerDisplayMode mode);
[DllImport(Libraries.Player, EntryPoint = "player_get_display_mode")]
- internal static extern int GetDisplayMode(IntPtr player, out int mode);
+ internal static extern PlayerErrorCode GetDisplayMode(IntPtr player, out int mode);
[DllImport(Libraries.Player, EntryPoint = "player_set_display_visible")]
- internal static extern int SetDisplayVisible(IntPtr player, bool visible);
+ internal static extern PlayerErrorCode SetDisplayVisible(IntPtr player, bool visible);
[DllImport(Libraries.Player, EntryPoint = "player_is_display_visible")]
- internal static extern int IsDisplayVisible(IntPtr player, out bool visible);
+ internal static extern PlayerErrorCode IsDisplayVisible(IntPtr player, out bool visible);
[DllImport(Libraries.Player, EntryPoint = "player_set_display_rotation")]
- internal static extern int SetDisplayRotation(IntPtr player, int rotation);
+ internal static extern PlayerErrorCode SetDisplayRotation(IntPtr player, PlayerDisplayRotation rotation);
[DllImport(Libraries.Player, EntryPoint = "player_get_display_rotation")]
- internal static extern int GetDisplayRotation(IntPtr player, out int rotation);
+ internal static extern PlayerErrorCode GetDisplayRotation(IntPtr player, out int rotation);
[DllImport(Libraries.Player, EntryPoint = "player_set_display_roi_area")]
- internal static extern int SetDisplayRoi(IntPtr player, int x, int y, int width, int height);
+ internal static extern PlayerErrorCode SetDisplayRoi(IntPtr player, int x, int y, int width, int height);
[DllImport(Libraries.Player, EntryPoint = "player_get_content_info")]
- internal static extern int GetContentInfo(IntPtr player, int key, out IntPtr value);
+ internal static extern PlayerErrorCode GetContentInfo(IntPtr player, StreamMetadataKey key, out IntPtr value);
[DllImport(Libraries.Player, EntryPoint = "player_get_codec_info")]
- internal static extern int GetCodecInfo(IntPtr player, out IntPtr audioCodec, out IntPtr videoCodec);
+ internal static extern PlayerErrorCode GetCodecInfo(IntPtr player, out IntPtr audioCodec, out IntPtr videoCodec);
[DllImport(Libraries.Player, EntryPoint = "player_get_audio_stream_info")]
- internal static extern int GetAudioStreamInfo(IntPtr player, out int sampleRate, out int channel, out int bitRate);
+ internal static extern PlayerErrorCode GetAudioStreamInfo(IntPtr player, out int sampleRate, out int channel, out int bitRate);
[DllImport(Libraries.Player, EntryPoint = "player_get_video_stream_info")]
- internal static extern int GetVideoStreamInfo(IntPtr player, out int fps, out int bitRate);
+ internal static extern PlayerErrorCode GetVideoStreamInfo(IntPtr player, out int fps, out int bitRate);
[DllImport(Libraries.Player, EntryPoint = "player_get_album_art")]
- internal static extern int GetAlbumArt(IntPtr player, out IntPtr albumArt, out int size);
+ internal static extern PlayerErrorCode GetAlbumArt(IntPtr player, out IntPtr albumArt, out int size);
[DllImport(Libraries.Player, EntryPoint = "player_get_video_size")]
- internal static extern int GetVideoSize(IntPtr player, out int width, out int height);
+ internal static extern PlayerErrorCode GetVideoSize(IntPtr player, out int width, out int height);
[DllImport(Libraries.Player, EntryPoint = "player_get_duration")]
- internal static extern int GetDuration(IntPtr player, out int duration);
+ internal static extern PlayerErrorCode GetDuration(IntPtr player, out int duration);
[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_path")]
- internal static extern int SetSubtitlePath(IntPtr player, string path);
+ internal static extern PlayerErrorCode SetSubtitlePath(IntPtr player, string path);
[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_updated_cb")]
- internal static extern int SetSubtitleUpdatedCb(IntPtr player, SubtitleUpdatedCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetSubtitleUpdatedCb(IntPtr player,
+ SubtitleUpdatedCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_subtitle_updated_cb")]
- internal static extern int UnsetSubtitleUpdatedCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetSubtitleUpdatedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_set_subtitle_position_offset")]
- internal static extern int SetSubtitlePositionOffset(IntPtr player, int millisecond);
+ internal static extern PlayerErrorCode SetSubtitlePositionOffset(IntPtr player, int millisecond);
[DllImport(Libraries.Player, EntryPoint = "player_set_video_stream_changed_cb")]
- internal static extern int SetVideoStreamChangedCb(IntPtr player, VideoStreamChangedCallback callback, IntPtr userData);
+ internal static extern PlayerErrorCode SetVideoStreamChangedCb(IntPtr player,
+ VideoStreamChangedCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.Player, EntryPoint = "player_unset_video_stream_changed_cb")]
- internal static extern int UnsetVideoStreamChangedCb(IntPtr player);
+ internal static extern PlayerErrorCode UnsetVideoStreamChangedCb(IntPtr player);
[DllImport(Libraries.Player, EntryPoint = "player_get_track_count")]
- internal static extern int GetTrackCount(IntPtr player, int type, out int count);
+ internal static extern PlayerErrorCode GetTrackCount(IntPtr player, int type, out int count);
[DllImport(Libraries.Player, EntryPoint = "player_select_track")]
- internal static extern int SelectTrack(IntPtr player, int type, int index);
+ internal static extern PlayerErrorCode SelectTrack(IntPtr player, int type, int index);
[DllImport(Libraries.Player, EntryPoint = "player_get_current_track")]
- internal static extern int GetCurrentTrack(IntPtr player, int type, out int index);
+ internal static extern PlayerErrorCode GetCurrentTrack(IntPtr player, int type, out int index);
[DllImport(Libraries.Player, EntryPoint = "player_get_track_language_code")]
- internal static extern int GetTrackLanguageCode(IntPtr player, int type, int index, out IntPtr code);
+ internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, int type, int index, out IntPtr code);
+ }
+ internal class PlayerHandle : SafeHandle
+ {
+ protected PlayerHandle() : base(IntPtr.Zero, true)
+ {
+ }
+
+ public override bool IsInvalid => handle == IntPtr.Zero;
+
+ protected override bool ReleaseHandle()
+ {
+ var ret = Player.Destroy(handle);
+ if (ret != PlayerErrorCode.None)
+ {
+ Log.Debug(GetType().FullName, $"Failed to release native {GetType().Name}");
+ return false;
+ }
+
+ return true;
+ }
}
}
}
Player = owner;
bool available = false;
- int ret = Interop.Player.AudioEffectEqualizerIsAvailable(Player.GetHandle(), out available);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+
+ Interop.Player.AudioEffectEqualizerIsAvailable(Player.Handle, out available).
+ ThrowIfFailed("Failed to initialize the AudioEffect");
IsAvailable = available;
}
int count = 0;
- ret = Interop.Player.AudioEffectGetEqualizerBandsCount(Player.GetHandle(), out count);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+ Interop.Player.AudioEffectGetEqualizerBandsCount(Player.Handle, out count).
+ ThrowIfFailed("Failed to initialize the AudioEffect");
int min = 0;
int max = 0;
- ret = Interop.Player.AudioEffectGetEqualizerLevelRange(Player.GetHandle(), out min, out max);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the AudioEffect");
+ Interop.Player.AudioEffectGetEqualizerLevelRange(Player.Handle, out min, out max).
+ ThrowIfFailed("Failed to initialize the AudioEffect");
Count = count;
MinBandLevel = min;
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
Player.ValidateNotDisposed();
- PlayerErrorConverter.ThrowIfError(Interop.Player.AudioEffectEqualizerClear(Player.GetHandle()),
- "Failed to clear equalizer effect");
+ Interop.Player.AudioEffectEqualizerClear(Player.Handle).
+ ThrowIfFailed("Failed to clear equalizer effect");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
int frequency = 0;
int range = 0;
- int ret = Interop.Player.AudioEffectGetEqualizerBandFrequency(_owner.Player.GetHandle(), _index, out frequency);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize equalizer band");
+ Interop.Player.AudioEffectGetEqualizerBandFrequency(_owner.Player.Handle, _index, out frequency).
+ ThrowIfFailed("Failed to initialize equalizer band");
- ret = Interop.Player.AudioEffectGetEqualizerBandFrequencyRange(_owner.Player.GetHandle(), _index, out range);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize equalizer band");
+ Interop.Player.AudioEffectGetEqualizerBandFrequencyRange(_owner.Player.Handle, _index, out range).
+ ThrowIfFailed("Failed to initialize equalizer band");
Frequency = frequency;
FrequencyRange = range;
$"but got {value}.");
}
- int ret = Interop.Player.AudioEffectSetEqualizerBandLevel(_owner.Player.GetHandle(), _index, value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the level of the equalizer band, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the level of the equalizer band");
+ Interop.Player.AudioEffectSetEqualizerBandLevel(_owner.Player.Handle, _index, value).
+ ThrowIfFailed("Failed to set the level of the equalizer band");
}
/// <summary>
_owner.Player.ValidateNotDisposed();
int value = 0;
- int ret = Interop.Player.AudioEffectGetEqualizerBandLevel(_owner.Player.GetHandle(),
- _index, out value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to get the level of the equalizer band, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the level of the equalizer band");
+ Interop.Player.AudioEffectGetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
+ ThrowIfFailed("Failed to get the level of the equalizer band");
Log.Info(PlayerLog.Tag, "get level : " + value);
return value;
}
internal override void OnAttached(Player player)
{
- // TODO test buffer if we need to use GCHandle
- int ret = Interop.Player.SetMemoryBuffer(player.GetHandle(), _buffer, _buffer.Length);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the memory buffer, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the memory buffer");
+ Interop.Player.SetMemoryBuffer(player.Handle, _buffer, _buffer.Length).
+ ThrowIfFailed("Failed to set the memory buffer");
}
}
}
throw new ArgumentOutOfRangeException(nameof(value), value, "the buffer max size can't be zero.");
}
- int ret = Interop.Player.SetMediaStreamBufferMaxSize(_owner.Player.GetHandle(), (int)_streamType, value);
-
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the buffer max size");
+ Interop.Player.SetMediaStreamBufferMaxSize(_owner.Player.Handle, _streamType, value).
+ ThrowIfFailed("Failed to set the buffer max size");
_bufferMaxSize = value;
}
$"The threshold can't be greater than 100, but got { value }.");
}
- int ret = Interop.Player.SetMediaStreamBufferMinThreshold(_owner.Player.GetHandle(), (int)_streamType, value);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the buffer minimum threshold");
+ Interop.Player.SetMediaStreamBufferMinThreshold(_owner.Player.Handle, _streamType, value).
+ ThrowIfFailed("Failed to set the buffer minimum threshold");
_threshold = value;
}
player.MediaStreamVideoBufferStatusChanged += MediaStreamBufferStatusChanged;
}
- int ret = Interop.Player.SetMediaStreamBufferMaxSize(player.GetHandle(), (int)_streamType, _bufferMaxSize);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the media stream configuration");
+ Interop.Player.SetMediaStreamBufferMaxSize(player.Handle, _streamType, _bufferMaxSize).
+ ThrowIfFailed("Failed to initialize the media stream configuration");
- ret = Interop.Player.SetMediaStreamBufferMinThreshold(player.GetHandle(), (int)_streamType, _threshold);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the media stream configuration");
+ Interop.Player.SetMediaStreamBufferMinThreshold(player.Handle, _streamType, _threshold).
+ ThrowIfFailed("Failed to initialize the media stream configuration");
}
internal void OnPlayerUnset(Player player)
_player.ValidatePlayerState(PlayerState.Paused, PlayerState.Playing, PlayerState.Ready);
- int ret = Interop.Player.PushMediaStream(_player.GetHandle(), packet.GetHandle());
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to push the packet to the player, " + (PlayerError)ret);
- }
-
- PlayerErrorConverter.ThrowIfError(ret, "Failed to push the packet to the player");
+ Interop.Player.PushMediaStream(_player.Handle, packet.GetHandle()).
+ ThrowIfFailed("Failed to push the packet to the player");
}
private void SetMediaStreamInfo(StreamType streamType, MediaFormat mediaFormat)
try
{
ptr = mediaFormat.AsNativeHandle();
- int ret = Interop.Player.SetMediaStreamInfo(_player.GetHandle(), (int)streamType, ptr);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the media stream info, " + (PlayerError)ret);
- }
-
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the media stream info");
+ Interop.Player.SetMediaStreamInfo(_player.Handle, (int)streamType, ptr).
+ ThrowIfFailed("Failed to set the media stream info");
}
finally
{
/// <seealso cref="Player.SetSource(MediaSource)"/>
public sealed class MediaUriSource : MediaSource
{
+ // TODO consider using Uri class.
/// <summary>
/// Initialize a new instance of the MediaUriSource class with the specified uri.</summary>
/// <param name="uri">The uri string.</param>
internal override void OnAttached(Player player)
{
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetUri(player.GetHandle(), Uri),
- "Failed to set the source with specified uri");
+ Interop.Player.SetUri(player.Handle, Uri).ThrowIfFailed("Failed to set the source with specified uri");
}
}
}
/// Initialize a new instance of the PlaybackInterruptedEventArgs class.
/// </summary>
/// <param name="status">The enum value indicating the reason.</param>
- public PlaybackInterruptedEventArgs(PlaybackIntrruptionReason reason)
+ public PlaybackInterruptedEventArgs(PlaybackInterruptionReason reason)
{
Reason = reason;
}
/// <summary>
/// Gets the reason.
/// </summary>
- public PlaybackIntrruptionReason Reason { get; }
+ public PlaybackInterruptionReason Reason { get; }
public override string ToString()
{
using System.Diagnostics;
using System.IO;
using System.Threading;
+using static Tizen.Multimedia.Interop;
namespace Tizen.Multimedia
{
/// It also provides functions to adjust the configurations of the player such as playback rate, volume, looping etc.
/// Note that only one video player can be played at one time.
/// </remarks>
- public sealed class Player : IDisposable
+ public class Player : IDisposable
{
- private IntPtr _handle = IntPtr.Zero;
+ private PlayerHandle _handle;
/// <summary>
/// Occurs when playback of a media is finished.
public Player()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
- try
- {
- int ret = Interop.Player.Create(out _handle);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to create player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to create player");
- RetrieveProperties();
- RegisterCallbacks();
+ Interop.Player.Create(out _handle).ThrowIfFailed("Failed to create player");
- AudioEffect = new AudioEffect(this);
- }
- catch (Exception)
- {
- if (_handle != IntPtr.Zero)
- {
- Interop.Player.Destroy(_handle);
- }
- throw;
- }
+ Debug.Assert(_handle != null);
+
+ RetrieveProperties();
+
+ AudioEffect = new AudioEffect(this);
}
private void RetrieveProperties()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
- PlayerErrorConverter.ThrowIfError(Interop.Player.GetVolume(_handle, out _volume, out _volume),
- "Failed to initialize the player");
+ Interop.Player.GetVolume(Handle, out _volume, out _volume).
+ ThrowIfFailed("Failed to initialize the player");
+
+ Interop.Player.GetAudioLatencyMode(Handle, out _audioLatencyMode).
+ ThrowIfFailed("Failed to initialize the player");
- int value = 0;
- PlayerErrorConverter.ThrowIfError(Interop.Player.GetAudioLatencyMode(_handle, out value),
- "Failed to initialize the player");
- _audioLatencyMode = (AudioLatencyMode)value;
+ Interop.Player.IsLooping(Handle, out _isLooping).ThrowIfFailed("Failed to initialize the player");
- PlayerErrorConverter.ThrowIfError(Interop.Player.IsLooping(_handle, out _isLooping),
- "Failed to initialize the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
+ private bool _callbackRegistered;
+
private void RegisterCallbacks()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
+
+ if (_callbackRegistered)
+ {
+ return;
+ }
RegisterSubtitleUpdatedCallback();
RegisterErrorOccurredCallback();
RegisterPlaybackInterruptedCallback();
RegisterMediaStreamSeekCallback();
RegisterPlaybackCompletedCallback();
RegisterVideoFrameDecodedCallback();
- }
- ~Player()
- {
- Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
- Dispose(false);
+ _callbackRegistered = true;
}
- internal IntPtr GetHandle()
+ public IntPtr Handle
{
- ValidateNotDisposed();
- return _handle;
+ get
+ {
+ ValidateNotDisposed();
+ return _handle.DangerousGetHandle();
+ }
}
internal void ValidatePlayerState(params PlayerState[] desiredStates)
$"Current State : { curState }, Valid State : { string.Join(", ", desiredStates) }.");
}
-#region Properties
-#region Network configuration
+ #region Properties
+ #region Network configuration
private string _cookie = "";
private string _userAgent = "";
throw new ArgumentNullException(nameof(value), "Cookie can't be null.");
}
- int ret = Interop.Player.SetStreamingCookie(_handle, value, value.Length);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the cookie to the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the cookie to the player");
+ Interop.Player.SetStreamingCookie(Handle, value, value.Length).
+ ThrowIfFailed("Failed to set the cookie to the player");
_cookie = value;
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
throw new ArgumentNullException(nameof(value), "UserAgent can't be null.");
}
- int ret = Interop.Player.SetStreamingUserAgent(_handle, value, value.Length);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the user agent to the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the user agent to the player");
+ Interop.Player.SetStreamingUserAgent(Handle, value, value.Length).
+ ThrowIfFailed("Failed to set the user agent to the player");
_userAgent = value;
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
}
-#endregion
+ #endregion
/// <summary>
/// Gets the state of the player.
}
int state = 0;
- int ret = Interop.Player.GetState(_handle, out state);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to retrieve the state of the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to retrieve the state of the player");
+ Interop.Player.GetState(Handle, out state).ThrowIfFailed("Failed to retrieve the state of the player");
Debug.Assert(Enum.IsDefined(typeof(PlayerState), state));
}
ValidationUtil.ValidateEnum(typeof(AudioLatencyMode), value);
- int ret = Interop.Player.SetAudioLatencyMode(_handle, (int)value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the audio latency mode of the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the audio latency mode of the player");
+ Interop.Player.SetAudioLatencyMode(Handle, value).
+ ThrowIfFailed("Failed to set the audio latency mode of the player");
_audioLatencyMode = value;
}
return;
}
- int ret = Interop.Player.SetLooping(_handle, value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the looping state of the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the looping state of the player");
+ Interop.Player.SetLooping(Handle, value).ThrowIfFailed("Failed to set the looping state of the player");
_isLooping = value;
}
}
-#region Display methods
+ #region Display methods
private PlayerDisplay _display;
- private int SetDisplay(PlayerDisplay display)
+ private PlayerErrorCode SetDisplay(PlayerDisplay display)
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (display == null)
{
Log.Info(PlayerLog.Tag, "set display to none");
- return Interop.Player.SetDisplay(_handle, PlayerDisplayType.None, IntPtr.Zero);
+ return Interop.Player.SetDisplay(Handle, PlayerDisplayType.None, IntPtr.Zero);
}
Log.Info(PlayerLog.Tag, "set display to " + display.Type + " (" + display.EvasObject + ")");
Debug.Assert(Enum.IsDefined(typeof(PlayerDisplayType), display.Type));
Debug.Assert(display.EvasObject != null);
- return Interop.Player.SetDisplay(_handle, display.Type, display.EvasObject);
+ return Interop.Player.SetDisplay(Handle, display.Type, display.EvasObject);
}
private void ReplaceDisplay(PlayerDisplay newDisplay)
}
}
- PlayerErrorConverter.ThrowIfError(SetDisplay(value), "Failed to set the display to the player");
+ SetDisplay(value).ThrowIfFailed("Failed to set the display to the player");
ReplaceDisplay(value);
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
}
-#endregion
+ #endregion
private PlayerTrackInfo _audioTrack;
/// </summary>
public AudioEffect AudioEffect { get; }
-#endregion
+ #endregion
-#region Dispose support
+ #region Dispose support
private bool _disposed;
public void Dispose()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
Dispose(true);
- GC.SuppressFinalize(this);
}
private void Dispose(bool disposing)
}
_source = null;
- if (_handle != IntPtr.Zero)
+ if (_handle != null)
{
- Interop.Player.Destroy(_handle);
- _handle = IntPtr.Zero;
+ _handle.Dispose();
}
_disposed = true;
}
}
}
- internal bool IsDisposed
- {
- get
- {
- Log.Info(PlayerLog.Tag, "get disposed : " + _disposed);
- return _disposed;
- }
- }
-#endregion
+ internal bool IsDisposed => _disposed;
+ #endregion
-#region Methods
+ #region Methods
/// <summary>
/// Gets the mute state.
ValidateNotDisposed();
bool value = false;
- PlayerErrorConverter.ThrowIfError(Interop.Player.IsMuted(_handle, out value),
- "Failed to get the mute state of the player");
+ Interop.Player.IsMuted(Handle, out value).ThrowIfFailed("Failed to get the mute state of the player");
Log.Info(PlayerLog.Tag, "get mute : " + value);
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
ValidateNotDisposed();
- int ret = Interop.Player.SetMute(_handle, mute);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the mute state of the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the mute state of the player");
+ Interop.Player.SetMute(Handle, mute).ThrowIfFailed("Failed to set the mute state of the player");
}
/// <summary>
int start = 0;
int current = 0;
- int ret = Interop.Player.GetStreamingDownloadProgress(_handle, out start, out current);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get download progress");
+ Interop.Player.GetStreamingDownloadProgress(Handle, out start, out current).
+ ThrowIfFailed("Failed to get download progress");
Log.Info(PlayerLog.Tag, "get download progress : " + start + ", " + current);
return new DownloadProgress(start, current);
}
-#region Volume
+ #region Volume
private float _volume;
/// <summary>
$"Valid volume range is 0 <= value <= 1.0, but got { value }.");
}
- int ret = Interop.Player.SetVolume(_handle, value, value);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the volume of the player");
+ Interop.Player.SetVolume(Handle, value, value).
+ ThrowIfFailed("Failed to set the volume of the player");
}
/// <summary>
ValidateNotDisposed();
float value = 0.0F;
- int ret = Interop.Player.GetVolume(_handle, out value, out value);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the volume of the player");
+ Interop.Player.GetVolume(Handle, out value, out value).
+ ThrowIfFailed("Failed to get the volume of the player");
return value;
}
-#endregion
+ #endregion
/// <summary>
/// Sets the subtitle path for playback.
/// The externalstorage privilege(http://tizen.org/privilege/externalstorage) must be added if any files are used to play located in the external storage.</para>
/// </remarks>
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
- /// <exception cref="ArgumentException">The specified path does not exist.</exception>
+ /// <exception cref="ArgumentException"><paramref name="path"/> is an empty string.</exception>
+ /// <exception cref="FileNotFoundException">The specified path does not exist.</exception>
/// <exception cref="ArgumentNullException">The path is null.</exception>
public void SetSubtitle(string path)
{
throw new ArgumentNullException(nameof(path));
}
+ if (path.Length == 0)
+ {
+ throw new ArgumentException("The path is empty.", nameof(path));
+ }
+
if (!File.Exists(path))
{
throw new FileNotFoundException($"The specified file does not exist.", path);
}
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePath(_handle, path),
- "Failed to set the subtitle path to the player");
+ Interop.Player.SetSubtitlePath(Handle, path).
+ ThrowIfFailed("Failed to set the subtitle path to the player");
+
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
ValidatePlayerState(PlayerState.Idle);
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePath(_handle, null),
- "Failed to clear the subtitle of the player");
+ Interop.Player.SetSubtitlePath(Handle, null).
+ ThrowIfFailed("Failed to clear the subtitle of the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
/// </summary>
/// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
- /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The player is not in the valid state.\n
+ /// - or -\n
+ /// No subtitle is set.
+ /// </exception>
+ /// <seealso cref="SetSubtitle(string)"/>
public void SetSubtitleOffset(int offset)
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetSubtitlePositionOffset(_handle, offset),
- "Failed to the subtitle offset of the player");
+ var err = Interop.Player.SetSubtitlePositionOffset(Handle, offset);
+
+ if (err == PlayerErrorCode.FeatureNotSupported)
+ {
+ throw new InvalidOperationException("No subtitle set");
+ }
+
+ err.ThrowIfFailed("Failed to the subtitle offset of the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
private void Prepare()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
- int ret = Interop.Player.Prepare(_handle);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to prepare the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to prepare the player");
+ Interop.Player.Prepare(Handle).ThrowIfFailed("Failed to prepare the player");
+ }
+
+ /// <summary>
+ /// Invoked when
+ /// </summary>
+ protected virtual void OnPreparing()
+ {
+ RegisterCallbacks();
}
/// <summary>
/// <exception cref="InvalidOperationException">No source is set.</exception>
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
/// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
- public Task PrepareAsync()
+ public virtual Task PrepareAsync()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (_source == null)
ValidatePlayerState(PlayerState.Idle);
+ OnPreparing();
+
var completionSource = new TaskCompletionSource<bool>();
SetPreparing();
/// </remarks>
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
/// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
- public void Unprepare()
+ public virtual void Unprepare()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (State == PlayerState.Idle)
}
ValidatePlayerState(PlayerState.Ready, PlayerState.Paused, PlayerState.Playing);
- PlayerErrorConverter.ThrowIfError(Interop.Player.Unprepare(_handle),
- "Failed to unprepare the player");
+ Interop.Player.Unprepare(Handle).ThrowIfFailed("Failed to unprepare the player");
if (_source != null)
{
/// <seealso cref="Stop"/>
/// <seealso cref="Pause"/>
/// <seealso cref="PlaybackCompleted"/>
- public void Start()
+ public virtual void Start()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (State == PlayerState.Playing)
}
ValidatePlayerState(PlayerState.Ready, PlayerState.Paused);
- PlayerErrorConverter.ThrowIfError(Interop.Player.Start(_handle), "Failed to start the player");
+ Interop.Player.Start(Handle).ThrowIfFailed("Failed to start the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
/// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
/// <seealso cref="Start"/>
/// <seealso cref="Pause"/>
- public void Stop()
+ public virtual void Stop()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (State == PlayerState.Ready)
}
ValidatePlayerState(PlayerState.Paused, PlayerState.Playing);
- PlayerErrorConverter.ThrowIfError(Interop.Player.Stop(_handle), "Failed to stop the player");
+ Interop.Player.Stop(Handle).ThrowIfFailed("Failed to stop the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
/// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
/// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
/// <seealso cref="Start"/>
- public void Pause()
+ public virtual void Pause()
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
if (State == PlayerState.Paused)
ValidatePlayerState(PlayerState.Playing);
- PlayerErrorConverter.ThrowIfError(Interop.Player.Pause(_handle), "Failed to pause the player");
+ Interop.Player.Pause(Handle).ThrowIfFailed("Failed to pause the player");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
using (var cbKeeper = ObjectKeeper.Get(cb))
{
- PlayerErrorConverter.ThrowIfError(
- Interop.Player.CaptureVideo(_handle, cb, IntPtr.Zero),
- "Failed to capture the video");
+ Interop.Player.CaptureVideo(Handle, cb)
+ .ThrowIfFailed("Failed to capture the video");
return await t.Task;
}
int playPosition = 0;
- PlayerErrorConverter.ThrowIfError(Interop.Player.GetPlayPosition(_handle, out playPosition),
- "Failed to get the play position of the player");
+ Interop.Player.GetPlayPosition(Handle, out playPosition).
+ ThrowIfFailed("Failed to get the play position of the player");
Log.Info(PlayerLog.Tag, "get play position : " + playPosition);
Interop.Player.SeekCompletedCallback cb)
{
Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
- int ret = Interop.Player.SetPlayPosition(_handle, milliseconds, accurate, cb, IntPtr.Zero);
+ var ret = Interop.Player.SetPlayPosition(Handle, milliseconds, accurate, cb, IntPtr.Zero);
//Note that we assume invalid param error is returned only when the position value is invalid.
- if (ret == (int)PlayerErrorCode.InvalidArgument)
+ if (ret == PlayerErrorCode.InvalidArgument)
{
throw new ArgumentOutOfRangeException(nameof(milliseconds), milliseconds,
"The position is not valid.");
}
- if (ret != (int)PlayerErrorCode.None)
+ if (ret != PlayerErrorCode.None)
{
Log.Error(PlayerLog.Tag, "Failed to set play position, " + (PlayerError)ret);
}
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set play position");
+ ret.ThrowIfFailed("Failed to set play position");
}
/// <summary>
ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetPlaybackRate(_handle, rate),
- "Failed to set the playback rate.");
+ Interop.Player.SetPlaybackRate(Handle, rate).ThrowIfFailed("Failed to set the playback rate.");
Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
}
ValidatePlayerState(PlayerState.Idle);
- PlayerErrorConverter.ThrowIfError(Interop.Player.SetAudioPolicyInfo(_handle, policy.Handle),
- "Failed to set the audio stream policy to the player");
- Log.Debug(PlayerLog.Tag, PlayerLog.Leave);
+ Interop.Player.SetAudioPolicyInfo(Handle, policy.Handle).
+ ThrowIfFailed("Failed to set the audio stream policy to the player");
}
-#endregion
+ #endregion
-#region Callback registrations
+ #region Callback registrations
private void RegisterSubtitleUpdatedCallback()
{
_subtitleUpdatedCallback = (duration, text, _) =>
SubtitleUpdated?.Invoke(this, new SubtitleUpdatedEventArgs(duration, text));
};
- int ret = Interop.Player.SetSubtitleUpdatedCb(_handle, _subtitleUpdatedCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to initialize the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to initialize the player");
+ Interop.Player.SetSubtitleUpdatedCb(Handle, _subtitleUpdatedCallback).
+ ThrowIfFailed("Failed to initialize the player");
}
private void RegisterPlaybackCompletedCallback()
Log.Debug(PlayerLog.Tag, "completed callback");
PlaybackCompleted?.Invoke(this, EventArgs.Empty);
};
- int ret = Interop.Player.SetCompletedCb(_handle, _playbackCompletedCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set PlaybackCompleted, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set PlaybackCompleted");
+ Interop.Player.SetCompletedCb(Handle, _playbackCompletedCallback).
+ ThrowIfFailed("Failed to set PlaybackCompleted");
}
private void RegisterPlaybackInterruptedCallback()
{
_playbackInterruptedCallback = (code, _) =>
{
- if (!Enum.IsDefined(typeof(PlaybackIntrruptionReason), code))
+ if (!Enum.IsDefined(typeof(PlaybackInterruptionReason), code))
{
return;
}
Log.Warn(PlayerLog.Tag, "interrupted reason : " + code);
- PlaybackInterrupted?.Invoke(this,
- new PlaybackInterruptedEventArgs((PlaybackIntrruptionReason)code));
+ PlaybackInterrupted?.Invoke(this, new PlaybackInterruptedEventArgs(code));
};
- int ret = Interop.Player.SetInterruptedCb(_handle, _playbackInterruptedCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set PlaybackInterrupted, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set PlaybackInterrupted");
+
+ Interop.Player.SetInterruptedCb(Handle, _playbackInterruptedCallback).
+ ThrowIfFailed("Failed to set PlaybackInterrupted");
}
private void RegisterErrorOccurredCallback()
{
_playbackErrorCallback = (code, _) =>
{
- if (!Enum.IsDefined(typeof(PlayerError), code))
- {
- return;
- }
//TODO handle service disconnected error.
Log.Warn(PlayerLog.Tag, "error code : " + code);
ErrorOccurred?.Invoke(this, new PlayerErrorOccurredEventArgs((PlayerError)code));
};
- int ret = Interop.Player.SetErrorCb(_handle, _playbackErrorCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set PlaybackError, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set PlaybackError");
+
+ Interop.Player.SetErrorCb(Handle, _playbackErrorCallback).
+ ThrowIfFailed("Failed to set PlaybackError");
}
private void RegisterVideoFrameDecodedCallback()
{
- _videoFrameDecodedCallback = (packetHandle,_) =>
+ _videoFrameDecodedCallback = (packetHandle, _) =>
{
var handler = VideoFrameDecoded;
if (handler != null)
}
};
- int ret = Interop.Player.SetVideoFrameDecodedCb(_handle, _videoFrameDecodedCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the VideoFrameDecoded, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to register the VideoFrameDecoded");
+ Interop.Player.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback).
+ ThrowIfFailed("Failed to register the VideoFrameDecoded");
}
private void RegisterVideoStreamChangedCallback()
VideoStreamChanged?.Invoke(this, new VideoStreamChangedEventArgs(height, width, fps, bitrate));
};
- int ret = Interop.Player.SetVideoStreamChangedCb(GetHandle(), _videoStreamChangedCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the video stream changed callback, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the video stream changed callback");
+
+ Interop.Player.SetVideoStreamChangedCb(Handle, _videoStreamChangedCallback).
+ ThrowIfFailed("Failed to set the video stream changed callback");
}
private void RegisterBufferingCallback()
BufferingProgressChanged?.Invoke(this, new BufferingProgressChangedEventArgs(percent));
};
- int ret = Interop.Player.SetBufferingCb(_handle, _bufferingProgressCallback, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set BufferingProgress, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set BufferingProgress");
+ Interop.Player.SetBufferingCb(Handle, _bufferingProgressCallback).
+ ThrowIfFailed("Failed to set BufferingProgress");
}
private void RegisterMediaStreamBufferStatusCallback()
Debug.Assert(Enum.IsDefined(typeof(MediaStreamBufferStatus), status));
Log.Debug(PlayerLog.Tag, "audio buffer status : " + status);
MediaStreamAudioBufferStatusChanged?.Invoke(this,
- new MediaStreamBufferStatusChangedEventArgs((MediaStreamBufferStatus)status));
+ new MediaStreamBufferStatusChangedEventArgs(status));
};
_mediaStreamVideoBufferStatusChangedCallback = (status, _) =>
{
Debug.Assert(Enum.IsDefined(typeof(MediaStreamBufferStatus), status));
Log.Debug(PlayerLog.Tag, "video buffer status : " + status);
MediaStreamVideoBufferStatusChanged?.Invoke(this,
- new MediaStreamBufferStatusChangedEventArgs((MediaStreamBufferStatus)status));
+ new MediaStreamBufferStatusChangedEventArgs(status));
};
RegisterMediaStreamBufferStatusCallback(StreamType.Audio, _mediaStreamAudioBufferStatusChangedCallback);
private void RegisterMediaStreamBufferStatusCallback(StreamType streamType,
Interop.Player.MediaStreamBufferStatusCallback cb)
{
- int ret = Interop.Player.SetMediaStreamBufferStatusCb(_handle, (int)streamType,
- cb, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to SetMediaStreamBufferStatus, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to SetMediaStreamBufferStatus");
+ Interop.Player.SetMediaStreamBufferStatusCb(Handle, streamType, cb).
+ ThrowIfFailed("Failed to SetMediaStreamBufferStatus");
}
private void RegisterMediaStreamSeekCallback()
private void RegisterMediaStreamSeekCallback(StreamType streamType, Interop.Player.MediaStreamSeekCallback cb)
{
- int ret = Interop.Player.SetMediaStreamSeekCb(_handle, (int)streamType,
- cb, IntPtr.Zero);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to SetMediaStreamSeek, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to SetMediaStreamSeek");
+ Interop.Player.SetMediaStreamSeekCb(Handle, streamType, cb).
+ ThrowIfFailed("Failed to SetMediaStreamSeek");
}
-#endregion
+ #endregion
-#region Preparing state
+ #region Preparing state
private int _isPreparing;
{
Interlocked.Exchange(ref _isPreparing, 0);
}
-#endregion
+ #endregion
}
}
ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
- int ret = Interop.Player.SetDisplayMode(Player.GetHandle(), (int)value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set display mode, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set display mode");
+ Interop.Player.SetDisplayMode(Player.Handle, value).
+ ThrowIfFailed("Failed to set display mode");
_displayMode = value;
}
return;
}
- int ret = Interop.Player.SetDisplayVisible(Player.GetHandle(), value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the visible state of the display, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the visible state of the display");
+ Interop.Player.SetDisplayVisible(Player.Handle, value).
+ ThrowIfFailed("Failed to set the visible state of the display");
_isVisible = value;
}
ValidationUtil.ValidateEnum(typeof(PlayerDisplayRotation), value);
- int ret = Interop.Player.SetDisplayRotation(Player.GetHandle(), (int)value);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the rotation state of the display, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the rotation state of the display");
+ Interop.Player.SetDisplayRotation(Player.Handle, value).
+ ThrowIfFailed("Failed to set the rotation state of the display");
_rotation = value;
}
$"The height of the roi can't be less than or equal to zero.");
}
- PlayerErrorConverter.ThrowIfError(
- Interop.Player.SetDisplayRoi(Player.GetHandle(), roi.X, roi.Y, roi.Width, roi.Height),
- "Failed to set the roi");
+ Interop.Player.SetDisplayRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
+ ThrowIfFailed("Failed to set the roi");
}
}
}
/// Specifies the reason for the playback interruption.
/// </summary>
/// <seealso cref="Player.PlaybackInterrupted"/>
- public enum PlaybackIntrruptionReason
+ public enum PlaybackInterruptionReason
{
ResourceConflict = 4
}
ServiceDisconnected = PlayerErrorClass | 0x0d
}
- internal static class PlayerErrorConverter
+ internal static class PlayerErrorCodeExtensions
{
- internal static void ThrowIfError(int errorCode, string errorMessage)
+ internal static void ThrowIfFailed(this PlayerErrorCode err, string message)
{
- if (errorCode == (int)PlayerErrorCode.None)
+ if (err == PlayerErrorCode.None)
{
return;
}
- PlayerErrorCode err = (PlayerErrorCode)errorCode;
- string msg = $"{ (errorMessage ?? "Operation failed") } : { err.ToString() }.";
+ string msg = $"{ (message ?? "Operation failed") } : { err.ToString() }.";
- switch ((PlayerErrorCode)errorCode)
+ switch (err)
{
case PlayerErrorCode.InvalidArgument:
case PlayerErrorCode.InvalidUri:
throw new ArgumentException(msg);
+
case PlayerErrorCode.NoSuchFile:
throw new FileNotFoundException(msg);
case PlayerErrorCode.OutOfMemory:
- case PlayerErrorCode.NoSpaceOnDevice:
throw new OutOfMemoryException(msg);
+ case PlayerErrorCode.NoSpaceOnDevice:
+ throw new IOException(msg);
+
case PlayerErrorCode.PermissionDenied:
- case PlayerErrorCode.InvalidOperation:
- case PlayerErrorCode.InvalidState:
- case PlayerErrorCode.FeatureNotSupported:
- case PlayerErrorCode.SeekFailed:
+ throw new UnauthorizedAccessException(msg);
+
case PlayerErrorCode.NotSupportedFile:
- case PlayerErrorCode.ConnectionFailed:
- case PlayerErrorCode.VideoCaptureFailed:
+ case PlayerErrorCode.FeatureNotSupported:
+ throw new NotSupportedException(msg);
+
case PlayerErrorCode.DrmExpired:
case PlayerErrorCode.DrmNoLicense:
case PlayerErrorCode.DrmFutureUse:
case PlayerErrorCode.DrmNotPermitted:
+ // TODO consider another exception.
+ case PlayerErrorCode.InvalidOperation:
+ case PlayerErrorCode.InvalidState:
+ case PlayerErrorCode.SeekFailed:
+ case PlayerErrorCode.ConnectionFailed:
+ case PlayerErrorCode.VideoCaptureFailed:
throw new InvalidOperationException(msg);
case PlayerErrorCode.NoBufferSpace:
throw new Exception(msg);
}
}
+
+ internal static class PlayerErrorConverter
+ {
+ internal static void ThrowIfError(int errorCode, string errorMessage)
+ {
+ }
+ }
/// <summary>
/// The exception that is thrown when there is no available space in a buffer.
/// </summary>
_owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
int count = 0;
- int ret = Interop.Player.GetTrackCount(_owner.GetHandle(), _streamType, out count);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get count of the track");
+ Interop.Player.GetTrackCount(_owner.Handle, _streamType, out count).
+ ThrowIfFailed("Failed to get count of the track");
Log.Info(PlayerLog.Tag, "get count : " + count);
return count;
}
try
{
- int ret = Interop.Player.GetTrackLanguageCode(
- _owner.GetHandle(), _streamType, index, out code);
-
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the selected language of the player");
+ Interop.Player.GetTrackLanguageCode(_owner.Handle, _streamType, index, out code).
+ ThrowIfFailed("Failed to get the selected language of the player");
string result = Marshal.PtrToStringAnsi(code);
_owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
int value = 0;
- int ret = Interop.Player.GetCurrentTrack(_owner.GetHandle(), _streamType, out value);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the selected index of the player");
+
+ Interop.Player.GetCurrentTrack(_owner.Handle, _streamType, out value).
+ ThrowIfFailed("Failed to get the selected index of the player");
Log.Debug(PlayerLog.Tag, "get selected index : " + value);
return value;
}
_owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
- int ret = Interop.Player.SelectTrack(_owner.GetHandle(), _streamType, index);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to set the selected index of the player, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to set the selected index of the player");
+ Interop.Player.SelectTrack(_owner.Handle, _streamType, index).
+ ThrowIfFailed("Failed to set the selected index of the player");
}
}
int size;
IntPtr art;
- int ret = Interop.Player.GetAlbumArt(Player.GetHandle(), out art, out size);
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the album art");
+ Interop.Player.GetAlbumArt(Player.Handle, out art, out size).
+ ThrowIfFailed("Failed to get the album art");
if (art == IntPtr.Zero || size == 0)
{
IntPtr videoPtr = IntPtr.Zero;
try
{
- int ret = Interop.Player.GetCodecInfo(Player.GetHandle(), out audioPtr, out videoPtr);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to get codec info, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get codec info");
+ Interop.Player.GetCodecInfo(Player.Handle, out audioPtr, out videoPtr).
+ ThrowIfFailed("Failed to get codec info");
if (audioInfo)
{
Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
int duration = 0;
- PlayerErrorConverter.ThrowIfError(Interop.Player.GetDuration(Player.GetHandle(), out duration),
- "Failed to get the duration");
+ Interop.Player.GetDuration(Player.Handle, out duration).
+ ThrowIfFailed("Failed to get the duration");
Log.Info(PlayerLog.Tag, "get duration : " + duration);
return duration;
int channels = 0;
int bitRate = 0;
- int ret = Interop.Player.GetAudioStreamInfo(Player.GetHandle(),
- out sampleRate, out channels, out bitRate);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to auido stream info, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get audio stream info");
+ Interop.Player.GetAudioStreamInfo(Player.Handle, out sampleRate, out channels, out bitRate).
+ ThrowIfFailed("Failed to get audio stream info");
// TODO should we check value is zero and return null?
int fps = 0;
int bitRate = 0;
- int ret = Interop.Player.GetVideoStreamInfo(Player.GetHandle(), out fps, out bitRate);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to video stream info, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the video stream info");
+
+ Interop.Player.GetVideoStreamInfo(Player.Handle, out fps, out bitRate).
+ ThrowIfFailed("Failed to get the video stream info");
// TODO should we check value is zero and return null?
int height = 0;
int width = 0;
- int ret = Interop.Player.GetVideoSize(Player.GetHandle(), out width, out height);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to video size, " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, "Failed to get the video size");
+
+ Interop.Player.GetVideoSize(Player.Handle, out width, out height).
+ ThrowIfFailed("Failed to get the video size");
return new Size(width, height);
}
try
{
- int ret = Interop.Player.GetContentInfo(Player.GetHandle(), (int)key, out ptr);
- if (ret != (int)PlayerErrorCode.None)
- {
- Log.Error(PlayerLog.Tag, "Failed to get the meta data with the key" + key + ", " + (PlayerError)ret);
- }
- PlayerErrorConverter.ThrowIfError(ret, $"Failed to get the meta data with the key '{ key }'");
-
+ Interop.Player.GetContentInfo(Player.Handle, key, out ptr).
+ ThrowIfFailed($"Failed to get the meta data with the key '{ key }'");
return Marshal.PtrToStringAnsi(ptr);
}