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("Failed to get display mode");
74 ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
76 Native.SetMode(Player.Handle, value).
77 ThrowIfFailed("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("Failed to get the visible state of the display");
101 Native.SetVisible(Player.Handle, value).ThrowIfFailed("Failed to set the visible state of the display");
106 /// Gets or sets the rotation of the display.
108 /// <value><see cref="Rotation.Rotate0"/>, <see cref="Rotation.Rotate90"/>, <see cref="Rotation.Rotate180"/>,
109 /// <see cref="Rotation.Rotate270"/>.</value>
110 /// <exception cref="InvalidOperationException">
111 /// Operation failed; internal error.
113 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
114 /// <exception cref="ArgumentException">The specified value to set is invalid.</exception>
115 /// <since_tizen> 3 </since_tizen>
116 public Rotation Rotation
120 Native.GetRotation(Player.Handle, out var value).
121 ThrowIfFailed("Failed to get the rotation state of the display");
127 ValidationUtil.ValidateEnum(typeof(Rotation), value);
129 Native.SetRotation(Player.Handle, value).
130 ThrowIfFailed("Failed to set the rotation state of the display");
135 /// Sets the roi(region of interest).
137 /// <param name="roi">The region.</param>
139 /// To set roi, <see cref="Mode"/> must be set to <see cref="PlayerDisplayMode.Roi"/> first.
141 /// <exception cref="InvalidOperationException">
142 /// Operation failed; internal error.<br/>
144 /// <see cref="Mode"/> is not set to <see cref="PlayerDisplayMode.Roi"/>.
146 /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
147 /// <exception cref="ArgumentOutOfRangeException">The width or the height is less than or equal to zero.</exception>
148 /// <since_tizen> 3 </since_tizen>
149 public void SetRoi(Rectangle roi)
153 throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
154 $"The width of the roi can't be less than or equal to zero.");
158 throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
159 $"The height of the roi can't be less than or equal to zero.");
162 if (Mode != PlayerDisplayMode.Roi)
164 throw new InvalidOperationException("Mode is not set to Roi");
167 Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
168 ThrowIfFailed("Failed to set the roi");