/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using Native = Interop.Display;
namespace Tizen.Multimedia
{
///
/// Provides a means to configure display settings for video .
///
/// 3
public class PlayerDisplaySettings
{
///
/// This constructor supports the product infrastructure and is not intended to be used directly from application code.
///
/// 4
[EditorBrowsable(EditorBrowsableState.Never)]
protected PlayerDisplaySettings(Player player)
{
if (player == null)
{
throw new ArgumentNullException(nameof(player));
}
Player = player;
}
internal static PlayerDisplaySettings Create(Player player) => new PlayerDisplaySettings(player);
///
/// Gets the player of this instance.
///
/// The of this instance.
/// 4
protected Player Player { get; }
///
/// Gets or sets the .
///
///
/// Operation failed; internal error.
///
/// The player has already been disposed of.
/// The specified value to set is invalid.
/// 3
public PlayerDisplayMode Mode
{
get
{
Native.GetMode(Player.Handle, out var value).
ThrowIfFailed("Failed to get display mode");
return value;
}
set
{
ValidationUtil.ValidateEnum(typeof(PlayerDisplayMode), value);
Native.SetMode(Player.Handle, value).
ThrowIfFailed("Failed to set display mode");
}
}
///
/// Gets or sets the value indicating whether the display is visible.
///
/// true if the display is visible; otherwise false.
///
/// Operation failed; internal error.
///
/// The player has already been disposed of.
/// 3
public bool IsVisible
{
get
{
Native.IsVisible(Player.Handle, out var value).
ThrowIfFailed("Failed to get the visible state of the display");
return value;
}
set
{
Native.SetVisible(Player.Handle, value).ThrowIfFailed("Failed to set the visible state of the display");
}
}
///
/// Gets or sets the rotation of the display.
///
/// , , ,
/// .
///
/// Operation failed; internal error.
///
/// The player has already been disposed of.
/// The specified value to set is invalid.
/// 3
public Rotation Rotation
{
get
{
Native.GetRotation(Player.Handle, out var value).
ThrowIfFailed("Failed to get the rotation state of the display");
return value;
}
set
{
ValidationUtil.ValidateEnum(typeof(Rotation), value);
Native.SetRotation(Player.Handle, value).
ThrowIfFailed("Failed to set the rotation state of the display");
}
}
///
/// Sets the roi(region of interest).
///
/// The region.
///
/// To set roi, must be set to first.
///
///
/// Operation failed; internal error.
/// -or-
/// is not set to .
///
/// The player has already been disposed of.
/// The width or the height is less than or equal to zero.
/// 3
public void SetRoi(Rectangle roi)
{
if (roi.Width <= 0)
{
throw new ArgumentOutOfRangeException(nameof(roi), roi.Width,
$"The width of the roi can't be less than or equal to zero.");
}
if (roi.Height <= 0)
{
throw new ArgumentOutOfRangeException(nameof(roi), roi.Height,
$"The height of the roi can't be less than or equal to zero.");
}
if (Mode != PlayerDisplayMode.Roi)
{
throw new InvalidOperationException("Mode is not set to Roi");
}
Native.SetRoi(Player.Handle, roi.X, roi.Y, roi.Width, roi.Height).
ThrowIfFailed("Failed to set the roi");
}
}
}