2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.ComponentModel;
19 using System.Diagnostics;
20 using Native = Interop.Display;
22 namespace Tizen.Multimedia
25 /// Provides a means to configure display settings for video <see cref="Player"/>.
27 /// <since_tizen> 3 </since_tizen>
28 public class PlayerDisplaySettings
31 /// This constructor supports the product infrastructure and is not intended to be used directly from application code.
33 /// <since_tizen> 4 </since_tizen>
34 [EditorBrowsable(EditorBrowsableState.Never)]
35 protected PlayerDisplaySettings(Player player)
39 throw new ArgumentNullException(nameof(player));
45 internal static PlayerDisplaySettings Create(Player player) => new PlayerDisplaySettings(player);
48 /// Gets the player of this instance.
50 /// <value>The <see cref="Player"/> of this <see cref="PlayerDisplaySettings"/> instance.</value>
51 /// <since_tizen> 4 </since_tizen>
52 protected Player Player { get; }
55 /// Gets or sets the <see cref="PlayerDisplayMode"/>.
57 /// <exception cref="InvalidOperationException">
58 /// Operation failed; internal error.
60 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
61 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
62 /// <since_tizen> 3 </since_tizen>
63 public PlayerDisplayMode Mode
67 Native.GetMode(Player.Handle, out var value).
68 ThrowIfFailed(Player, "Failed to get display mode");
74 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
76 Native.SetMode(Player.Handle, value).
77 ThrowIfFailed(Player, "Failed to set display mode");
82 /// Gets or sets the value indicating whether the display is visible.
84 /// <value>true if the display is visible; otherwise false.</value>
85 /// <exception cref="InvalidOperationException">
86 /// Operation failed; internal error.
88 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
89 /// <since_tizen> 3 </since_tizen>
94 Native.IsVisible(Player.Handle, out var value).
95 ThrowIfFailed(Player, "Failed to get the visible state of the display");
101 Native.SetVisible(Player.Handle, value).ThrowIfFailed(
102 Player, "Failed to set the visible state of the display");
107 /// Gets or sets the rotation of the display.
109 /// <value><see cref="Rotation.Rotate0"/>, <see cref="Rotation.Rotate90"/>, <see cref="Rotation.Rotate180"/>,
110 /// <see cref="Rotation.Rotate270"/>.</value>
111 /// <exception cref="InvalidOperationException">
112 /// Operation failed; internal error.
114 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
115 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
116 /// <since_tizen> 3 </since_tizen>
117 public Rotation Rotation
121 Native.GetRotation(Player.Handle, out var value).
122 ThrowIfFailed(Player, "Failed to get the rotation state of the display");
128 ValidationUtil.ValidateEnum(typeof(Rotation), value);
130 Native.SetRotation(Player.Handle, value).
131 ThrowIfFailed(Player, "Failed to set the rotation state of the display");
136 /// Sets the roi(region of interest).
138 /// <param name="roi">The region.</param>
140 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
142 /// <exception cref="InvalidOperationException">
143 /// Operation failed; internal error.<br/>
145 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>.
147 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
148 /// <exception cref="ArgumentOutOfRangeException">The width or the height is less than or equal to zero.</exception>
149 /// <since_tizen> 3 </since_tizen>
150 public void SetRoi(Rectangle roi)
154 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
155 $"The width of the roi can't be less than or equal to zero.");
159 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
160 $"The height of the roi can't be less than or equal to zero.");
163 if (Mode != PlayerDisplayMode.Roi)
165 throw new InvalidOperationException("Mode is not set to Roi");
168 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
169 ThrowIfFailed(Player, "Failed to set the roi");