From 1ac060f79e31233be9b326d7f132d2ef0a9d5ae8 Mon Sep 17 00:00:00 2001 From: Ravi Kiran K N Date: Tue, 19 Jul 2016 15:14:02 +0530 Subject: [PATCH] Player: Updated doxygen comments. Corrected scope for subtitle path variable Set result for async failed case. Corrected equalizer band constructor Change-Id: I194fb9d13a9683b8749ce39232ad5189bacf469d Signed-off-by: Ravi Kiran K N --- .../Player/DownloadProgress.cs | 3 +- src/Tizen.Multimedia/Player/EqualizerBand.cs | 41 +- .../Player/MediaBufferSource.cs | 29 +- src/Tizen.Multimedia/Player/MediaSource.cs | 13 +- src/Tizen.Multimedia/Player/MediaUriSource.cs | 37 +- src/Tizen.Multimedia/Player/Player.cs | 1052 +++++++++-------- .../Player/ProgressiveDownloadStatus.cs | 43 +- src/Tizen.Multimedia/Player/Subtitle.cs | 415 ++++--- src/Tizen.Multimedia/Player/SubtitleTrack.cs | 1 + 9 files changed, 829 insertions(+), 805 deletions(-) diff --git a/src/Tizen.Multimedia/Player/DownloadProgress.cs b/src/Tizen.Multimedia/Player/DownloadProgress.cs index f10598168..87b63535d 100644 --- a/src/Tizen.Multimedia/Player/DownloadProgress.cs +++ b/src/Tizen.Multimedia/Player/DownloadProgress.cs @@ -18,7 +18,8 @@ namespace Tizen.Multimedia /// DownloadProgress /// /// - /// Contains Download progress + /// Contains Download progress. Download object is null initially. + /// It is created only when playback starts. /// public class DownloadProgress { diff --git a/src/Tizen.Multimedia/Player/EqualizerBand.cs b/src/Tizen.Multimedia/Player/EqualizerBand.cs index 150d0002c..f47692fa9 100644 --- a/src/Tizen.Multimedia/Player/EqualizerBand.cs +++ b/src/Tizen.Multimedia/Player/EqualizerBand.cs @@ -22,35 +22,38 @@ namespace Tizen.Multimedia /// public class EqualizerBand { - internal int _level; - internal int _frequency; - internal int _range; + internal int _level; + internal int _frequency; + internal int _range; - internal EqualizerBand(int level, int frequency, int range) - { - } + internal EqualizerBand(int level, int frequency, int range) + { + _level = level; + _frequency = frequency; + _range = range; + } /// /// Set/Get new gain in decibel that is set to the given band [dB] /// /// int level - public int Level - { - set - { - _level = value; - } - get - { - return _level; - } - } + public int Level + { + set + { + _level = value; + } + get + { + return _level; + } + } /// /// Get frequency of the given band [dB] . /// /// int frequency - public int Frequency + public int Frequency { get { @@ -62,7 +65,7 @@ namespace Tizen.Multimedia /// Getfrequency range of the given band [dB]. /// /// int range - public int Range + public int Range { get { diff --git a/src/Tizen.Multimedia/Player/MediaBufferSource.cs b/src/Tizen.Multimedia/Player/MediaBufferSource.cs index ba6f93369..b19c929d5 100644 --- a/src/Tizen.Multimedia/Player/MediaBufferSource.cs +++ b/src/Tizen.Multimedia/Player/MediaBufferSource.cs @@ -12,18 +12,25 @@ using System; namespace Tizen.Multimedia { - public class MediaBufferSource : MediaSource - { - internal byte[] _buffer; + /// + /// The MediaBufferSource class used to set source to the player. + /// + /// + /// MediaBufferSource object is created using buffer containing + /// media content. Then the object is set to the player as source. + /// + public class MediaBufferSource : MediaSource + { + internal byte[] _buffer; - /// - /// Constructor - sets media buffer - /// source buffer - public MediaBufferSource(byte[] buffer) - { - _buffer = buffer; - } + /// + /// Constructor - sets media buffer + /// source buffer + public MediaBufferSource(byte[] buffer) + { + _buffer = buffer; + } - } + } } diff --git a/src/Tizen.Multimedia/Player/MediaSource.cs b/src/Tizen.Multimedia/Player/MediaSource.cs index f5a3b097b..2dc273eb1 100644 --- a/src/Tizen.Multimedia/Player/MediaSource.cs +++ b/src/Tizen.Multimedia/Player/MediaSource.cs @@ -14,8 +14,15 @@ using System; namespace Tizen.Multimedia { - public abstract class MediaSource - { - } + /// + /// The MediaSource class used to set source to the player. + /// + /// + /// This is abstract class. Actual source classes + /// should inherit this class. + /// + public abstract class MediaSource + { + } } diff --git a/src/Tizen.Multimedia/Player/MediaUriSource.cs b/src/Tizen.Multimedia/Player/MediaUriSource.cs index 9bf589337..331f362f7 100644 --- a/src/Tizen.Multimedia/Player/MediaUriSource.cs +++ b/src/Tizen.Multimedia/Player/MediaUriSource.cs @@ -12,23 +12,30 @@ using System; namespace Tizen.Multimedia { - public class MediaUriSource : MediaSource - { - private string _uri; + /// + /// The MediaUriSource class used to set source to the player. + /// + /// + /// MediaUriSource object is created using url string of the media + /// Then the object is set to the player as source. + /// + public class MediaUriSource : MediaSource + { + private string _uri; - /// - /// Constructor - /// uri string - public MediaUriSource(string uri) - { - _uri = uri; - } + /// + /// Constructor + /// uri string + public MediaUriSource(string uri) + { + _uri = uri; + } - internal string GetUri() - { - return _uri; - } + internal string GetUri() + { + return _uri; + } - } + } } diff --git a/src/Tizen.Multimedia/Player/Player.cs b/src/Tizen.Multimedia/Player/Player.cs index abd16045d..30d618140 100755 --- a/src/Tizen.Multimedia/Player/Player.cs +++ b/src/Tizen.Multimedia/Player/Player.cs @@ -15,10 +15,10 @@ using System.Runtime.InteropServices; namespace Tizen.Multimedia { - static internal class PlayerLog - { - internal const string LogTag = "Tizen.Multimedia.Player"; - } + static internal class PlayerLog + { + internal const string LogTag = "Tizen.Multimedia.Player"; + } /// /// The Player class provides APIs required for playback. @@ -29,169 +29,175 @@ namespace Tizen.Multimedia /// of the player such as playback rate, volume, looping etc. And, event handlers /// handles are provided to handle various playback events (like playback error/completion) /// - public class Player : IDisposable + public class Player : IDisposable { - internal PlayerState _state; - internal float _leftVolume; - internal float _rightVolume; - internal int _audioLatencyMode; - internal bool _mute; - internal bool _isLooping; - internal Display _display; - internal Subtitle _subtitle; - internal AudioEffect _audioEffect; - internal StreamInformation _streamInformation; - internal StreamingConfiguration _streamingConfiguration; - internal IntPtr _playerHandle; - - private bool _disposed = false; - private EventHandler _playbackCompleted; - private Interop.Player.PlaybackCompletedCallback _playbackCompletedCallback; - private EventHandler _playbackInterrupted; - private Interop.Player.PlaybackInterruptedCallback _playbackInterruptedCallback; - private EventHandler _playbackError; - private Interop.Player.PlaybackErrorCallback _playbackErrorCallback; - - //TODO: Uncomment this after MediaPacket is implemented. - //private EventHandler _videoFrameDecoded; - //private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback; - - - /// - /// Player constructor. - public Player() - { - int ret; + internal PlayerState _state; + internal float _leftVolume; + internal float _rightVolume; + internal int _audioLatencyMode; + internal bool _mute; + internal bool _isLooping; + internal Display _display; + internal Subtitle _subtitle; + internal AudioEffect _audioEffect; + internal StreamInformation _streamInformation; + internal StreamingConfiguration _streamingConfiguration; + internal IntPtr _playerHandle; + + private bool _disposed = false; + private EventHandler _playbackCompleted; + private Interop.Player.PlaybackCompletedCallback _playbackCompletedCallback; + private EventHandler _playbackInterrupted; + private Interop.Player.PlaybackInterruptedCallback _playbackInterruptedCallback; + private EventHandler _playbackError; + private Interop.Player.PlaybackErrorCallback _playbackErrorCallback; + + //TODO: Uncomment this after MediaPacket is implemented. + //private EventHandler _videoFrameDecoded; + //private Interop.Player.VideoFrameDecodedCallback _videoFrameDecodedCallback; - ret = Interop.Player.Create(out _playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to create player" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to create player"); - } - // Initial get values - ret = Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to get volume levels" + ret); - } + /// + /// Player constructor. + public Player() + { + int ret; - ret = Interop.Player.GetAudioLatencyMode(_playerHandle, out _audioLatencyMode); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to get Audio latency mode" + ret); - } + ret = Interop.Player.Create(out _playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to create player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to create player"); + } - ret = Interop.Player.IsMuted(_playerHandle, out _mute); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to get mute status" + ret); - } + // Initial get values + ret = Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to get volume levels" + ret); + } - ret = Interop.Player.IsLooping(_playerHandle, out _isLooping); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to get loop status" + ret); - } + ret = Interop.Player.GetAudioLatencyMode(_playerHandle, out _audioLatencyMode); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to get Audio latency mode" + ret); + } + ret = Interop.Player.IsMuted(_playerHandle, out _mute); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to get mute status" + ret); + } - // AudioEffect - _audioEffect = new AudioEffect(); - _audioEffect._playerHandle = _playerHandle; + ret = Interop.Player.IsLooping(_playerHandle, out _isLooping); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to get loop status" + ret); + } - // Display - _display = new Display(DisplayType.Evas /* Default value? */); - _display._playerHandle = _playerHandle; - // StreamingConfiguration - _streamingConfiguration = new StreamingConfiguration(_playerHandle); + // AudioEffect + _audioEffect = new AudioEffect(); + _audioEffect._playerHandle = _playerHandle; - // StreamInformation - _streamInformation = new StreamInformation(); - _streamInformation._playerHandle = _playerHandle; - _streamInformation._contentInfo = new PlayerContentInfo(); - _streamInformation._contentInfo._playerHandle = _playerHandle; + // Display + _display = new Display(DisplayType.Evas /* Default value? */); + _display._playerHandle = _playerHandle; + // StreamingConfiguration + _streamingConfiguration = new StreamingConfiguration(_playerHandle); - Log.Debug(PlayerLog.LogTag, "player created : "+ _playerHandle); - } + // StreamInformation + _streamInformation = new StreamInformation(); + _streamInformation._playerHandle = _playerHandle; + _streamInformation._contentInfo = new PlayerContentInfo(); + _streamInformation._contentInfo._playerHandle = _playerHandle; - /// - /// Player destructor - /// - ~Player() - { - Dispose(false); - } + Log.Debug(PlayerLog.LogTag, "player created : " + _playerHandle); + } - /// + /// + /// Player destructor + /// + ~Player() + { + Dispose(false); + } + + + /// /// PlaybackCompleted event is raised when playback of a media is finished /// public event EventHandler PlaybackCompleted - { - add - { - if(_playbackCompleted == null) { - RegisterPlaybackCompletedEvent(); - } - _playbackCompleted += value; + { + add + { + if(_playbackCompleted == null) + { + RegisterPlaybackCompletedEvent(); + } + _playbackCompleted += value; - } - remove - { - _playbackCompleted -= value; - if(_playbackCompleted == null) { - UnregisterPlaybackCompletedEvent(); - } - } - } + } + remove + { + _playbackCompleted -= value; + if(_playbackCompleted == null) + { + UnregisterPlaybackCompletedEvent(); + } + } + } /// /// PlaybackInterruped event is raised when playback of a media is interrupted /// public event EventHandler PlaybackInterruped - { - add - { - if(_playbackInterrupted == null) { - RegisterPlaybackInterruptedEvent(); - } - _playbackInterrupted += value; - } - remove - { - _playbackInterrupted -= value; - if(_playbackInterrupted == null) { - UnregisterPlaybackInterruptedEvent(); - } - } - } + { + add + { + if(_playbackInterrupted == null) + { + RegisterPlaybackInterruptedEvent(); + } + _playbackInterrupted += value; + } + remove + { + _playbackInterrupted -= value; + if(_playbackInterrupted == null) + { + UnregisterPlaybackInterruptedEvent(); + } + } + } /// /// PlaybackErrorOccured event is raised when any error occurs /// public event EventHandler PlaybackErrorOccured - { - add - { - if(_playbackError == null) { - RegisterPlaybackErrorEvent(); - } - _playbackError += value; - } - remove - { - _playbackError -= value; - if(_playbackError == null) { - UnregisterPlaybackErrorEvent(); - } - } - } + { + add + { + if(_playbackError == null) + { + RegisterPlaybackErrorEvent(); + } + _playbackError += value; + } + remove + { + _playbackError -= value; + if(_playbackError == null) + { + UnregisterPlaybackErrorEvent(); + } + } + } - #if _MEDIA_PACKET_ + #if _MEDIA_PACKET_ TODO: Uncomment this after MediaPacket is implemented. /// /// VideoFrameCaptured event is raised when a video frame is decoded @@ -220,17 +226,17 @@ namespace Tizen.Multimedia /// Get Player state. /// /// PlayerState - public PlayerState State + public PlayerState State { get { - int state; - int ret = Interop.Player.GetState(_playerHandle, out state); + int state; + int ret = Interop.Player.GetState(_playerHandle, out state); - if(ret != (int)PlayerError.None) - PlayerErrorFactory.ThrowException(ret, "Get player state failed"); + if(ret != (int)PlayerError.None) + PlayerErrorFactory.ThrowException(ret, "Get player state failed"); - return (PlayerState)state; + return (PlayerState)state; } } @@ -238,158 +244,153 @@ namespace Tizen.Multimedia /// Set/Get the left volume level. /// /// 0 to 1.0 that indicates left volume level - public float LeftVolume - { - set - { - int ret = Interop.Player.SetVolume(_playerHandle, value, _rightVolume); - - if(ret == (int)PlayerError.None) - { - _leftVolume = value; - } - else - { - Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set volume failed"); - } - } - get - { - //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); - return _leftVolume; - } - } + public float LeftVolume + { + set + { + int ret = Interop.Player.SetVolume(_playerHandle, value, _rightVolume); + + if(ret == (int)PlayerError.None) + { + _leftVolume = value; + } else + { + Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set volume failed"); + } + } + get + { + //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); + return _leftVolume; + } + } /// /// Set/Get the right volume level. /// /// 0 to 1.0 that indicates right volume level - public float RightVolume - { - set - { - int ret = Interop.Player.SetVolume(_playerHandle, _leftVolume, value); - - if(ret == (int)PlayerError.None) - { - _rightVolume = value; - } - else - { - Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set volume failed"); - } - } - get - { - //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); - return _rightVolume; - } - } + public float RightVolume + { + set + { + int ret = Interop.Player.SetVolume(_playerHandle, _leftVolume, value); + + if(ret == (int)PlayerError.None) + { + _rightVolume = value; + } else + { + Log.Error(PlayerLog.LogTag, "Set volume failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set volume failed"); + } + } + get + { + //Interop.Player.GetVolume(_playerHandle, out _leftVolume, out _rightVolume); + return _rightVolume; + } + } /// /// Set/Get the Audio Latency Mode. /// /// Low, Mid, High - public AudioLatencyMode AudioLatencyMode - { - set - { - if(_audioLatencyMode != (int)value) - { - int ret = Interop.Player.SetAudioLatencyMode(_playerHandle, (int)value); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Set audio latency mode failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set audio latency mode failed"); - } - else - { - _audioLatencyMode = (int)value; - } - } - } + public AudioLatencyMode AudioLatencyMode + { + set + { + if(_audioLatencyMode != (int)value) + { + int ret = Interop.Player.SetAudioLatencyMode(_playerHandle, (int)value); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Set audio latency mode failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set audio latency mode failed"); + } else + { + _audioLatencyMode = (int)value; + } + } + } - get - { - return (AudioLatencyMode)_audioLatencyMode; - } - } + get + { + return (AudioLatencyMode)_audioLatencyMode; + } + } /// /// Set/Get mute. /// /// true, false - public bool Mute - { - set - { - if(_mute != value) - { - int ret = Interop.Player.SetMute(_playerHandle, value); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Set mute failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set mute failed"); - } - else - { - _mute = value; - } - } - } - get - { - //Interop.Player.IsMuted(_playerHandle, out _mute); - return _mute; - } - } + public bool Mute + { + set + { + if(_mute != value) + { + int ret = Interop.Player.SetMute(_playerHandle, value); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Set mute failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set mute failed"); + } else + { + _mute = value; + } + } + } + get + { + //Interop.Player.IsMuted(_playerHandle, out _mute); + return _mute; + } + } /// /// Set/Get Loop play. /// /// true, false - public bool IsLooping - { - set - { - if(_isLooping != value) - { - int ret = Interop.Player.SetLooping(_playerHandle, value); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Set loop failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set loop failed"); - } - else - { - _isLooping = value; - } - } - } - get - { - //Interop.Player.IsLooping(_playerHandle, out _isLooping); - return _isLooping; - } - } + public bool IsLooping + { + set + { + if(_isLooping != value) + { + int ret = Interop.Player.SetLooping(_playerHandle, value); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Set loop failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set loop failed"); + } else + { + _isLooping = value; + } + } + } + get + { + //Interop.Player.IsLooping(_playerHandle, out _isLooping); + return _isLooping; + } + } /// /// Get play position. /// /// play position in milli seconds - public int PlayPosition + public int PlayPosition { get { - int playPosition; - int ret = Interop.Player.GetPlayPosition(_playerHandle, out playPosition); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to get play position, " + (PlayerError)ret); - } - return playPosition; + int playPosition; + int ret = Interop.Player.GetPlayPosition(_playerHandle, out playPosition); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to get play position, " + (PlayerError)ret); + } + return playPosition; } } @@ -397,45 +398,45 @@ namespace Tizen.Multimedia /// Set/Get Display. /// /// Display configuration - public Display Display - { - set - { - _display = value; - _display._playerHandle = _playerHandle; - } - get - { - return _display; - } - } + public Display Display + { + set + { + _display = value; + _display._playerHandle = _playerHandle; + } + get + { + return _display; + } + } /// /// Set/Get Subtitle. /// /// Subtitle configuration public Subtitle Subtitle - { - set - { - _subtitle = value; - _subtitle._playerHandle = _playerHandle; - _subtitle.Path = _subtitle._path; - } - get - { - return _subtitle; - } - } + { + set + { + _subtitle = value; + _subtitle._playerHandle = _playerHandle; + _subtitle._subPath = _subtitle._path; + } + get + { + return _subtitle; + } + } /// /// Get AudioEffect. /// /// AudioEffect object - public AudioEffect AudioEffect + public AudioEffect AudioEffect { - get + get { return _audioEffect; } @@ -445,7 +446,7 @@ namespace Tizen.Multimedia /// Get stream information. /// /// StreamInformation object - public StreamInformation StreamInformation + public StreamInformation StreamInformation { get { @@ -457,7 +458,7 @@ namespace Tizen.Multimedia /// Get StreamingConfiguration. /// /// StreamingConfiguration object - public StreamingConfiguration StreamingConfiguration + public StreamingConfiguration StreamingConfiguration { get { @@ -466,31 +467,34 @@ namespace Tizen.Multimedia } - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } /// /// Prepares the media player for playback. - public Task PrepareAsync() + public Task PrepareAsync() { - int ret; + int ret; var task = new TaskCompletionSource(); - Task.Factory.StartNew(() => { - Interop.Player.PrepareCallback cb = (IntPtr userData) => { + Task.Factory.StartNew(() => + { + Interop.Player.PrepareCallback cb = (IntPtr userData) => + { task.SetResult(true); return; }; - ret = Interop.Player.PrepareAsync(_playerHandle, cb, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to prepare player" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to prepare player"); - } - }); + ret = Interop.Player.PrepareAsync(_playerHandle, cb, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + task.SetResult(false); + Log.Error(PlayerLog.LogTag, "Failed to prepare player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to prepare player"); + } + }); return task.Task; } @@ -500,273 +504,275 @@ namespace Tizen.Multimedia /// If you want to use the player again, you will have to set the data URI and call prepare() again. public void Unprepare() { - int ret = Interop.Player.Unprepare(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to unprepare player" +(PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to unprepare player"); - } + int ret = Interop.Player.Unprepare(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to unprepare player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to unprepare player"); + } } /// /// Starts or resumes playback. public void Start() { - int ret = Interop.Player.Start(_playerHandle); - if( ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to start player" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to start player"); - } + int ret = Interop.Player.Start(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to start player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to start player"); + } } /// /// Stops playing media content. public void Stop() { - int ret = Interop.Player.Stop(_playerHandle); - if( ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to stop player" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to stop player"); - } + int ret = Interop.Player.Stop(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to stop player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to stop player"); + } } /// /// Pauses the player. public void Pause() { - int ret = Interop.Player.Pause(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to pause player" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to pause player"); - } + int ret = Interop.Player.Pause(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to pause player" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to pause player"); + } } - /// - /// sets media source for the player. - /// Mediasource - public void SetSource(MediaSource source) - { - int ret; - if(source.GetType() == typeof(MediaUriSource)) - { - ret = Interop.Player.SetUri(_playerHandle, ((MediaUriSource)source).GetUri()); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to seturi" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to set uri"); - } - } - else if(source.GetType() == typeof(MediaBufferSource)) - { - GCHandle pinnedArray = GCHandle.Alloc(((MediaBufferSource)source)._buffer, GCHandleType.Pinned); - IntPtr mem = pinnedArray.AddrOfPinnedObject(); - ret = Interop.Player.SetMemoryBuffer(_playerHandle, mem, ((MediaBufferSource)source)._buffer.Length); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to set memory buffer" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to set memory buffer"); - } - } - else if(source.GetType() == typeof(MediaStreamSource)) - { - // TODO: Handle MediaStream source after implementing MediaPacket module - ((MediaStreamSource)source).SetHandle(_playerHandle); - } - } + /// + /// sets media source for the player. + /// Mediasource + public void SetSource(MediaSource source) + { + int ret; + if(source.GetType() == typeof(MediaUriSource)) + { + ret = Interop.Player.SetUri(_playerHandle, ((MediaUriSource)source).GetUri()); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to seturi" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to set uri"); + } + } else if(source.GetType() == typeof(MediaBufferSource)) + { + GCHandle pinnedArray = GCHandle.Alloc(((MediaBufferSource)source)._buffer, GCHandleType.Pinned); + IntPtr mem = pinnedArray.AddrOfPinnedObject(); + ret = Interop.Player.SetMemoryBuffer(_playerHandle, mem, ((MediaBufferSource)source)._buffer.Length); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to set memory buffer" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to set memory buffer"); + } + } else if(source.GetType() == typeof(MediaStreamSource)) + { + // TODO: Handle MediaStream source after implementing MediaPacket module + ((MediaStreamSource)source).SetHandle(_playerHandle); + } + } /// /// Captures a video frame asynchronously. public Task CaptureVideoAsync() { - return Task.Factory.StartNew(() => CaptureVideoAsyncTask()).Result; + return Task.Factory.StartNew(() => CaptureVideoAsyncTask()).Result; } /// ///Sets the seek position for playback, asynchronously. /// Position to be set in milliseconds /// accurate seek or not - public Task SetPlayPositionAsync(int milliseconds, bool accurate) - { - var task = new TaskCompletionSource(); - - Task.Factory.StartNew(() => { - Interop.Player.SeekCompletedCallback cb = (IntPtr userData) => { - task.SetResult(true); - return; - }; - int ret = Interop.Player.SetPlayPosition(_playerHandle, milliseconds, accurate, cb, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to set playposition" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to set playposition"); - } - }); + public Task SetPlayPositionAsync(int milliseconds, bool accurate) + { + var task = new TaskCompletionSource(); + + Task.Factory.StartNew(() => + { + Interop.Player.SeekCompletedCallback cb = (IntPtr userData) => + { + task.SetResult(true); + return; + }; + int ret = Interop.Player.SetPlayPosition(_playerHandle, milliseconds, accurate, cb, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to set playposition" + (PlayerError)ret); + task.SetResult(false); + PlayerErrorFactory.ThrowException(ret, "Failed to set playposition"); + } + }); - return task.Task; + return task.Task; } - /// - /// sets playback rate - /// playback rate -5.0x to 5.0x - public void SetPlaybackRate(float rate) - { - int ret = Interop.Player.SetPlaybackRate(_playerHandle, rate); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Set playback rate failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "set playback rate failed"); - } - } + /// + /// sets playback rate + /// playback rate -5.0x to 5.0x + public void SetPlaybackRate(float rate) + { + int ret = Interop.Player.SetPlaybackRate(_playerHandle, rate); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Set playback rate failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "set playback rate failed"); + } + } - /// - /// sets audio stream policy - /// Audio Stream Policy - public void SetAudioStreamPolicy(AudioStreamPolicy policy) - { - int ret = Interop.Player.SetAudioPolicyInfo(_playerHandle, policy.Handle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Set Audio stream policy failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Set Audio stream policy failed"); - } - } + /// + /// sets audio stream policy + /// Audio Stream Policy + public void SetAudioStreamPolicy(AudioStreamPolicy policy) + { + int ret = Interop.Player.SetAudioPolicyInfo(_playerHandle, policy.Handle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Set Audio stream policy failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Set Audio stream policy failed"); + } + } - protected virtual void Dispose(bool disposing) - { - if(!_disposed) - { - if(disposing) - { - // To be used if there are any other disposable objects - } - if(_playerHandle != IntPtr.Zero) - { - Interop.Player.Destroy(_playerHandle); - _playerHandle = IntPtr.Zero; - } - _disposed = true; - } - } + protected virtual void Dispose(bool disposing) + { + if(!_disposed) + { + if(disposing) + { + // To be used if there are any other disposable objects + } + if(_playerHandle != IntPtr.Zero) + { + Interop.Player.Destroy(_playerHandle); + _playerHandle = IntPtr.Zero; + } + _disposed = true; + } + } - private void RegisterPlaybackCompletedEvent() - { - _playbackCompletedCallback = (IntPtr userData) => - { - PlaybackCompletedEventArgs eventArgs = new PlaybackCompletedEventArgs(); - _playbackCompleted?.Invoke(this, eventArgs); - }; - int ret = Interop.Player.SetCompletedCb(_playerHandle, _playbackCompletedCallback, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting PlaybackCompleted callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting PlaybackCompleted callback failed"); - } + private void RegisterPlaybackCompletedEvent() + { + _playbackCompletedCallback = (IntPtr userData) => + { + PlaybackCompletedEventArgs eventArgs = new PlaybackCompletedEventArgs(); + _playbackCompleted?.Invoke(this, eventArgs); + }; + int ret = Interop.Player.SetCompletedCb(_playerHandle, _playbackCompletedCallback, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting PlaybackCompleted callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting PlaybackCompleted callback failed"); + } - } + } - private void UnregisterPlaybackCompletedEvent() - { - int ret = Interop.Player.UnsetCompletedCb(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Unsetting PlaybackCompleted callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackCompleted callback failed"); - } + private void UnregisterPlaybackCompletedEvent() + { + int ret = Interop.Player.UnsetCompletedCb(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Unsetting PlaybackCompleted callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackCompleted callback failed"); + } - } + } - private void RegisterPlaybackInterruptedEvent() - { - _playbackInterruptedCallback = (int code, IntPtr userData) => - { - PlaybackInterruptedEventArgs eventArgs = new PlaybackInterruptedEventArgs(code); - _playbackInterrupted?.Invoke(this, eventArgs); - }; - int ret = Interop.Player.SetInterruptedCb(_playerHandle, _playbackInterruptedCallback, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting PlaybackInterrupted callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting PlaybackInterrupted callback failed"); - } - } + private void RegisterPlaybackInterruptedEvent() + { + _playbackInterruptedCallback = (int code, IntPtr userData) => + { + PlaybackInterruptedEventArgs eventArgs = new PlaybackInterruptedEventArgs(code); + _playbackInterrupted?.Invoke(this, eventArgs); + }; + int ret = Interop.Player.SetInterruptedCb(_playerHandle, _playbackInterruptedCallback, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting PlaybackInterrupted callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting PlaybackInterrupted callback failed"); + } + } - private void UnregisterPlaybackInterruptedEvent() - { - int ret = Interop.Player.UnsetInterruptedCb(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Unsetting PlaybackInterrupted callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackInterrupted callback failed"); - } - } + private void UnregisterPlaybackInterruptedEvent() + { + int ret = Interop.Player.UnsetInterruptedCb(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Unsetting PlaybackInterrupted callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackInterrupted callback failed"); + } + } - private void RegisterPlaybackErrorEvent() - { - _playbackErrorCallback = (int code, IntPtr userData) => - { - PlaybackErrorEventArgs eventArgs = new PlaybackErrorEventArgs(code); - _playbackError?.Invoke(this, eventArgs); - }; - int ret = Interop.Player.SetErrorCb(_playerHandle, _playbackErrorCallback, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting PlaybackError callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting PlaybackError callback failed"); - } + private void RegisterPlaybackErrorEvent() + { + _playbackErrorCallback = (int code, IntPtr userData) => + { + PlaybackErrorEventArgs eventArgs = new PlaybackErrorEventArgs(code); + _playbackError?.Invoke(this, eventArgs); + }; + int ret = Interop.Player.SetErrorCb(_playerHandle, _playbackErrorCallback, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting PlaybackError callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting PlaybackError callback failed"); + } - } + } - private void UnregisterPlaybackErrorEvent() - { - int ret = Interop.Player.UnsetErrorCb(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Unsetting PlaybackError callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackError callback failed"); - } + private void UnregisterPlaybackErrorEvent() + { + int ret = Interop.Player.UnsetErrorCb(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Unsetting PlaybackError callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Unsetting PlaybackError callback failed"); + } - } + } - private Task CaptureVideoAsyncTask() - { - TaskCompletionSource t = new TaskCompletionSource (); - Interop.Player.VideoCaptureCallback cb = (byte[] data, int width, int height, uint size, IntPtr userData) => { - VideoFrameCapture v = new VideoFrameCapture(data, width, height, size); - t.SetResult(v); - }; - - int ret = Interop.Player.CaptureVideo(_playerHandle, cb, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Failed to capture video" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Failed to capture video"); - } - return t.Task; - } + private Task CaptureVideoAsyncTask() + { + TaskCompletionSource t = new TaskCompletionSource(); + Interop.Player.VideoCaptureCallback cb = (byte[] data, int width, int height, uint size, IntPtr userData) => + { + VideoFrameCapture v = new VideoFrameCapture(data, width, height, size); + t.SetResult(v); + }; + int ret = Interop.Player.CaptureVideo(_playerHandle, cb, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Failed to capture video" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Failed to capture video"); + } + return t.Task; + } - #if _MEDIA_PACKET_ - TODO: Uncomment this when MediaPacket is implemented - private void RegisterVideoFrameDecodedEvent() - { - _videoFrameDecoded = (MediaPacket packet, IntPtr userData) => - { - VideoFrameDecodedEventArgs eventArgs = new VideoFrameDecodedEventArgs(); - _videoFrameDecoded?.Invoke(this, eventArgs); - }; - Interop.Player.SetErrorCb(_playerHandle, _videoFrameDecodedCallback, IntPtr.Zero); - } - private void UnregisterVideoFrameDecodedEvent() - { - Interop.Player.UnsetMediaPacketVideoFrameDecodedCb(_playerHandle); - } - #endif + #if _MEDIA_PACKET_ + //TODO: Uncomment this when MediaPacket is implemented + private void RegisterVideoFrameDecodedEvent() + { + _videoFrameDecoded = (MediaPacket packet, IntPtr userData) => + { + VideoFrameDecodedEventArgs eventArgs = new VideoFrameDecodedEventArgs(); + _videoFrameDecoded?.Invoke(this, eventArgs); + }; + Interop.Player.SetErrorCb(_playerHandle, _videoFrameDecodedCallback, IntPtr.Zero); + } + + private void UnregisterVideoFrameDecodedEvent() + { + Interop.Player.UnsetMediaPacketVideoFrameDecodedCb(_playerHandle); + } + #endif } } diff --git a/src/Tizen.Multimedia/Player/ProgressiveDownloadStatus.cs b/src/Tizen.Multimedia/Player/ProgressiveDownloadStatus.cs index d2213c550..3970c1659 100644 --- a/src/Tizen.Multimedia/Player/ProgressiveDownloadStatus.cs +++ b/src/Tizen.Multimedia/Player/ProgressiveDownloadStatus.cs @@ -18,41 +18,42 @@ namespace Tizen.Multimedia /// DownloadProgress /// /// - /// Contains Progressive download status + /// Contains Progressive download status. ProgressiveDownloadStatus object is null initially. + /// It is created only when playback starts. /// - public class ProgressiveDownloadStatus + public class ProgressiveDownloadStatus { - internal ulong _current; - internal ulong _totalSize; + internal ulong _current; + internal ulong _totalSize; - internal ProgressiveDownloadStatus(ulong current, ulong totalSize) - { - _current = current; - _totalSize = totalSize; - } + internal ProgressiveDownloadStatus(ulong current, ulong totalSize) + { + _current = current; + _totalSize = totalSize; + } /// /// Get current download position (bytes) /// /// current download position public ulong Current - { - get - { - return _current; - } - } + { + get + { + return _current; + } + } /// /// Get total size of the file (bytes) /// /// Total size of file (bytes) public ulong TotalSize - { - get - { - return _totalSize; - } - } + { + get + { + return _totalSize; + } + } } } \ No newline at end of file diff --git a/src/Tizen.Multimedia/Player/Subtitle.cs b/src/Tizen.Multimedia/Player/Subtitle.cs index 2d1dd3f7a..4a8342387 100644 --- a/src/Tizen.Multimedia/Player/Subtitle.cs +++ b/src/Tizen.Multimedia/Player/Subtitle.cs @@ -14,261 +14,252 @@ using System.Collections.Generic; namespace Tizen.Multimedia { - /// + /// /// Subtitle /// /// /// This class provides properties and events that are required for subtitle /// during playback. - /// - /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object. - /// Else, operations on subtitle object do not work. + /// + /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object. + /// Else, operations on subtitle object do not work. /// public class Subtitle { - internal IntPtr _playerHandle; - internal string _path; - private EventHandler _subtitleUpdated; - private Interop.Player.SubtitleUpdatedCallback _subtitleUpdatedCallback; + internal IntPtr _playerHandle; + internal string _path; - /// - /// Subtitle Constructor. - /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object. - /// Else, operations on subtitle object do not work. - /// subtitle path - public Subtitle(string path) - { - _path = path; - } + internal string _subPath + { + set + { + int ret = Interop.Player.SetSubtitlePath(_playerHandle, value); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting subtitle path failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting subtitle path failed"); + } + } + } + + + + private EventHandler _subtitleUpdated; + private Interop.Player.SubtitleUpdatedCallback _subtitleUpdatedCallback; + + /// + /// Subtitle Constructor. + /// Note: Newly created subtitle has to be set to the 'Subtitle' property of the player object. + /// Else, operations on subtitle object do not work. + /// subtitle path + public Subtitle(string path) + { + _path = path; + } /// /// Subtitle event is raised when the subtitle is updated /// public event EventHandler Updated - { - add - { - if(_subtitleUpdated == null) { - RegisterSubtitleUpdatedEvent(); - } - _subtitleUpdated += value; - } - remove - { - _subtitleUpdated -= value; - if(_subtitleUpdated == null) { - UnregisterSubtitleUpdatedEvent(); - } - } - } + { + add + { + if(_subtitleUpdated == null) + { + RegisterSubtitleUpdatedEvent(); + } + _subtitleUpdated += value; + } + remove + { + _subtitleUpdated -= value; + if(_subtitleUpdated == null) + { + UnregisterSubtitleUpdatedEvent(); + } + } + } /// /// Set position offset. /// /// position in milli seconds - public int Position - { - set - { - int ret = Interop.Player.SetSubtitlePositionOffset(_playerHandle, value); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting position offset failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting position offset failed"); - } - } - } + public int Position + { + set + { + int ret = Interop.Player.SetSubtitlePositionOffset(_playerHandle, value); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting position offset failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting position offset failed"); + } + } + } /// /// Get/Set Text track. /// /// Text track list - public IEnumerable TextTrack - { - get - { - string langCode; - int curTrack; - int ret; - int tracks = 0; - List textTrack = new List(); + public IEnumerable TextTrack + { + get + { + string langCode; + int curTrack; + int ret; + int tracks = 0; + List textTrack = new List(); - ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Text, out tracks); - if(ret == (int)PlayerError.None) - { - ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Text, out curTrack); - if(ret == (int)PlayerError.None && tracks > 0) - { - for(int idx = 0; idx < tracks; idx++) - { - bool activated = (curTrack == idx ? true : false); - ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Text, idx, out langCode); - if(ret == (int)PlayerError.None) - { - SubtitleTrack st = new SubtitleTrack(langCode, activated); - textTrack.Add(st); - } - else - { - Log.Error(PlayerLog.LogTag, "Getting text track language code failed" + (PlayerError)ret); - } - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting current track index failed" + (PlayerError)ret); - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting track count failed" + (PlayerError)ret); - } + ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Text, out tracks); + if(ret == (int)PlayerError.None) + { + ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Text, out curTrack); + if(ret == (int)PlayerError.None && tracks > 0) + { + for(int idx = 0; idx < tracks; idx++) + { + bool activated = (curTrack == idx ? true : false); + ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Text, idx, out langCode); + if(ret == (int)PlayerError.None) + { + SubtitleTrack st = new SubtitleTrack(langCode, activated); + textTrack.Add(st); + } else + { + Log.Error(PlayerLog.LogTag, "Getting text track language code failed" + (PlayerError)ret); + } + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting current track index failed" + (PlayerError)ret); + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting track count failed" + (PlayerError)ret); + } - return textTrack; - } - } + return textTrack; + } + } /// /// Get/Set Audio track. /// /// Audio track list - public IEnumerable AudioTrack - { - get - { - string langCode; - int curTrack; - int ret; - int tracks = 0; - List audioTrack = new List(); + public IEnumerable AudioTrack + { + get + { + string langCode; + int curTrack; + int ret; + int tracks = 0; + List audioTrack = new List(); - ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Audio, out tracks); - if(ret == (int)PlayerError.None) - { - ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Audio, out curTrack); - if(ret == (int)PlayerError.None && tracks > 0) - { - for(int idx = 0; idx < tracks; idx++) - { - bool activated = (curTrack == idx ? true : false); - ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Audio, idx, out langCode); - if(ret == (int)PlayerError.None) - { - SubtitleTrack st = new SubtitleTrack(langCode, activated); - audioTrack.Add(st); - } - else - { - Log.Error(PlayerLog.LogTag, "Getting audio track language code failed" + (PlayerError)ret); - } - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting audio track index failed" + (PlayerError)ret); - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting audio track count failed" + (PlayerError)ret); - } + ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Audio, out tracks); + if(ret == (int)PlayerError.None) + { + ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Audio, out curTrack); + if(ret == (int)PlayerError.None && tracks > 0) + { + for(int idx = 0; idx < tracks; idx++) + { + bool activated = (curTrack == idx ? true : false); + ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Audio, idx, out langCode); + if(ret == (int)PlayerError.None) + { + SubtitleTrack st = new SubtitleTrack(langCode, activated); + audioTrack.Add(st); + } else + { + Log.Error(PlayerLog.LogTag, "Getting audio track language code failed" + (PlayerError)ret); + } + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting audio track index failed" + (PlayerError)ret); + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting audio track count failed" + (PlayerError)ret); + } - return audioTrack; - } - } + return audioTrack; + } + } /// /// Get/Set video track. /// /// video track list - public IEnumerable VideoTrack - { - get - { - string langCode; - int curTrack; - int ret; - int tracks = 0; - List videoTrack = new List(); - - ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Video, out tracks); - if(ret == (int)PlayerError.None) - { - ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Video, out curTrack); - if(ret == (int)PlayerError.None && tracks > 0) - { - for(int idx = 0; idx < tracks; idx++) - { - bool activated = (curTrack == idx ? true : false); - ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Video, idx, out langCode); - if(ret == (int)PlayerError.None) - { - SubtitleTrack st = new SubtitleTrack(langCode, activated); - videoTrack.Add(st); - } - else - { - Log.Error(PlayerLog.LogTag, "Getting video track language code failed" + (PlayerError)ret); - } - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting video track index failed" + (PlayerError)ret); - } - } - else - { - Log.Error(PlayerLog.LogTag, "Getting video track count failed" + (PlayerError)ret); - } - - return videoTrack; - } - } + public IEnumerable VideoTrack + { + get + { + string langCode; + int curTrack; + int ret; + int tracks = 0; + List videoTrack = new List(); - /// - /// Set path. - /// - /// path string - public string Path - { - set - { - int ret = Interop.Player.SetSubtitlePath(_playerHandle, value); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting subtitle path failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting subtitle path failed"); - } - } - } + ret = Interop.Player.GetTrackCount(_playerHandle, (int)StreamType.Video, out tracks); + if(ret == (int)PlayerError.None) + { + ret = Interop.Player.GetCurrentTrack(_playerHandle, (int)StreamType.Video, out curTrack); + if(ret == (int)PlayerError.None && tracks > 0) + { + for(int idx = 0; idx < tracks; idx++) + { + bool activated = (curTrack == idx ? true : false); + ret = Interop.Player.GetTrackLanguageCode(_playerHandle, (int)StreamType.Video, idx, out langCode); + if(ret == (int)PlayerError.None) + { + SubtitleTrack st = new SubtitleTrack(langCode, activated); + videoTrack.Add(st); + } else + { + Log.Error(PlayerLog.LogTag, "Getting video track language code failed" + (PlayerError)ret); + } + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting video track index failed" + (PlayerError)ret); + } + } else + { + Log.Error(PlayerLog.LogTag, "Getting video track count failed" + (PlayerError)ret); + } + return videoTrack; + } + } - private void RegisterSubtitleUpdatedEvent() - { - _subtitleUpdatedCallback = (uint duration, string text, IntPtr userData) => - { - SubtitleUpdatedEventArgs eventArgs = new SubtitleUpdatedEventArgs(duration, text); - _subtitleUpdated?.Invoke(this, eventArgs); - }; - int ret = Interop.Player.SetSubtitleUpdatedCb(_playerHandle, _subtitleUpdatedCallback, IntPtr.Zero); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Setting subtitle updated callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Setting subtitle updated callback failed"); - } + private void RegisterSubtitleUpdatedEvent() + { + _subtitleUpdatedCallback = (uint duration, string text, IntPtr userData) => + { + SubtitleUpdatedEventArgs eventArgs = new SubtitleUpdatedEventArgs(duration, text); + _subtitleUpdated?.Invoke(this, eventArgs); + }; + int ret = Interop.Player.SetSubtitleUpdatedCb(_playerHandle, _subtitleUpdatedCallback, IntPtr.Zero); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Setting subtitle updated callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Setting subtitle updated callback failed"); + } - } + } - private void UnregisterSubtitleUpdatedEvent() - { - int ret = Interop.Player.UnsetSubtitleUpdatedCb(_playerHandle); - if(ret != (int)PlayerError.None) - { - Log.Error(PlayerLog.LogTag, "Unsetting subtitle updated callback failed" + (PlayerError)ret); - PlayerErrorFactory.ThrowException(ret, "Unsetting subtitle updated callback failed"); - } - } + private void UnregisterSubtitleUpdatedEvent() + { + int ret = Interop.Player.UnsetSubtitleUpdatedCb(_playerHandle); + if(ret != (int)PlayerError.None) + { + Log.Error(PlayerLog.LogTag, "Unsetting subtitle updated callback failed" + (PlayerError)ret); + PlayerErrorFactory.ThrowException(ret, "Unsetting subtitle updated callback failed"); + } + } } } \ No newline at end of file diff --git a/src/Tizen.Multimedia/Player/SubtitleTrack.cs b/src/Tizen.Multimedia/Player/SubtitleTrack.cs index d182a8385..4fb176753 100644 --- a/src/Tizen.Multimedia/Player/SubtitleTrack.cs +++ b/src/Tizen.Multimedia/Player/SubtitleTrack.cs @@ -26,6 +26,7 @@ namespace Tizen.Multimedia /// /// SubtitleTrack Constructor. + /// /// Language code string /// subtitle activated true/false public SubtitleTrack(string code, bool activated) -- 2.34.1