private PlaybackStateUpdatedEventArgs CreatePlaybackUpdatedEventArgs(IntPtr playbackHandle) { try { Native.GetPlaybackState(playbackHandle, out var playbackCode).ThrowIfError("Failed to get state."); Native.GetPlaybackPosition(playbackHandle, out var position).ThrowIfError("Failed to get position."); return(new PlaybackStateUpdatedEventArgs(playbackCode.ToPublic(), (long)position)); } catch (Exception e) { Log.Error(GetType().FullName, e.ToString()); } return(null); }
/// <summary> /// Returns the playback position set by the server. /// </summary> /// <returns>The playback position in milliseconds.</returns> /// <exception cref="InvalidOperationException"> /// The server has already been stopped.<br/> /// -or-<br/> /// An internal error occurs. /// </exception> /// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed.</exception> /// <seealso cref="MediaControlServer.SetPlaybackState(MediaControlPlaybackState, long)"/> /// <since_tizen> 4 </since_tizen> public long GetPlaybackPosition() { ThrowIfStopped(); IntPtr playbackHandle = IntPtr.Zero; try { Native.GetServerPlaybackHandle(Manager.Handle, ServerAppId, out playbackHandle).ThrowIfError("Failed to get playback."); Native.GetPlaybackPosition(playbackHandle, out var position).ThrowIfError("Failed to get position."); return((long)position); } finally { if (playbackHandle != IntPtr.Zero) { Native.DestroyPlayback(playbackHandle); } } }