using Tizen = Xamarin.Forms.PlatformConfiguration.Tizen;
/// <summary>
- /// @TODO: Comment
+ /// A custom ContentPage for displaying the video player
/// </summary>
public partial class VideoPlayer : ContentPageEx
{
+ /// <summary>
+ /// Enumeration for the state of the control area
+ /// </summary>
enum ControlAreaState
{
SHOW = 0,
AUTO,
};
- private int duration;
+ /// <summary>
+ /// The media duration in Milliseconds.
+ /// </summary>
+ private int sourceDuration;
+
+ /// <summary>
+ /// The instance of the player
+ /// </summary>
private Player playerInstance;
+
+ /// <summary>
+ /// The window of the full screen
+ /// </summary>
private ElmSharp.Window fullScreenWindow;
#if MULTIMEDIA_API_VERSION_1_0_55
private Display playerDisplayInstance;
#else
+ /// <summary>
+ /// The instance of the player display
+ /// </summary>
private PlayerDisplay playerDisplayInstance;
#endif
+ /// <summary>
+ /// The media source
+ /// </summary>
private MediaUriSource videoMediaSource;
+
+ /// <summary>
+ /// The height size(72)
+ /// </summary>
private double height72 = SizeUtils.GetHeightSize(72);
+ /// <summary>
+ /// The key name list to handle key event
+ /// </summary>
private string[] remoteKeys = new string[] { "Up", "Down", "Left", "Right", "XF86Menu" };
+
+ /// <summary>
+ /// The timer to handle the control area
+ /// </summary>
private IntPtr timer = default(IntPtr);
+
+ /// <summary>
+ /// The interval of the timer
+ /// </summary>
private double timerInterval = 5.0;
+ /// <summary>
+ /// Gets or sets whether play status is back forward or back rewind
+ /// </summary>
private bool IsInPlayBackRewFwd
{
set
}
}
+ /// <summary>
+ /// The value for play back forward index
+ /// </summary>
private int playBackForwardIndex;
+
+ /// <summary>
+ /// Gets or sets play back forward index
+ /// </summary>
private int PlayBackForwardIndex
{
set
}
}
+ /// <summary>
+ /// The value for play back rewind index
+ /// </summary>
private int playBackRewindIndex;
+ /// <summary>
+ /// Gets or sets play back rewind index
+ /// </summary>
private int PlayBackRewindIndex
{
set
}
}
+ /// <summary>
+ /// The value for the playback rate
+ /// </summary>
private float[] PlayBackRate = { 1, 2, 4 };
+ /// <summary>
+ /// Identifies the CurrenVideo bindable property
+ /// </summary>
public static readonly BindableProperty CurrentVideoProperty = BindableProperty.Create("CurrentVideo", typeof(MediaInformation), typeof(VideoPlayer), null);
+
+ /// <summary>
+ /// Gets or sets CurrentVideo
+ /// </summary>
public MediaInformation CurrentVideo
{
get { return (MediaInformation)GetValue(CurrentVideoProperty); }
set { SetValue(CurrentVideoProperty, value); }
}
+ /// <summary>
+ /// A constructor
+ /// </summary>
public VideoPlayer()
{
BindingContext = VideoTabViewModelLocator.ViewModel;
};
}
+ /// <summary>
+ /// Grabs the key of the remote controller
+ /// </summary>
private void GrabRemoteKeys()
{
foreach (var key in remoteKeys)
App.MainWindow.KeyDown += RemoteKeyDownListener;
}
+ /// <summary>
+ /// Ungrabs the key of the remote controller
+ /// </summary>
private void UngrabRemoteKeys()
{
App.MainWindow.KeyDown -= RemoteKeyDownListener;
}
}
+ /// <summary>
+ /// KeyDown will be triggered when key is preesd down
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">Information about the event</param>
private void RemoteKeyDownListener(object sender, ElmSharp.EvasKeyEventArgs e)
{
SetControlAreaState(ControlAreaState.AUTO);
}
+ /// <summary>
+ /// Sets the status of the control area
+ /// </summary>
+ /// <param name="state">The status to be set</param>
private void SetControlAreaState(ControlAreaState state)
{
switch (state)
}
}
+ /// <summary>
+ /// Initialize the timer of the player
+ /// </summary>
private void InitializeTimer()
{
Device.StartTimer(new TimeSpan(0, 0, 0, 0, 100), TimerElapsed);
}
+ /// <summary>
+ /// The previous status of the player
+ /// </summary>
PlayerState prevPlayerStatus = PlayerState.Idle;
+
+ /// <summary>
+ /// Display elapsed time of the media source
+ /// </summary>
+ /// <returns>If the player state is playing or paused, false; otherwise, true</returns>
private bool TimerElapsed()
{
Device.BeginInvokeOnMainThread(() =>
int playPosition = playerInstance.GetPlayPosition();
SetPlayTime(playPosition);
- progress.Progress = (double)playPosition / duration;
+ progress.Progress = (double)playPosition / sourceDuration;
DbgPort.D("Status : " + playerInstance.State + "/" + prevPlayerStatus + ", temp : " + playPosition + ", progress : " + progress.Progress.ToString());
if (prevPlayerStatus != playerInstance.State)
// TODO : check later, hotfix for VD GBM player
if ((PlayBackRewindIndex != 0 && playPosition < 4000)
- || PlayBackForwardIndex != 0 && playPosition > (duration - 6000))
+ || PlayBackForwardIndex != 0 && playPosition > (sourceDuration - 6000))
{
IsInPlayBackRewFwd = false;
playerInstance.SetPlaybackRate((PlayBackRate[0]));
return true;
}
+ /// <summary>
+ /// Initialize the player display
+ /// </summary>
private void InitializePlayerDisplay()
{
// Create Player Display and Window
SetControlAreaState(ControlAreaState.AUTO);
}
-
};
DbgPort.D("ElmSharp.Window has been created");
#if MULTIMEDIA_API_VERSION_1_0_55
DbgPort.D("Player Display has been created");
}
+ /// <summary>
+ /// Initialize the player
+ /// </summary>
private void InitializePlayer()
{
// Create Player Instance
playerInstance.SetSource(videoMediaSource);
}
+ /// <summary>
+ /// Prepares the media player for playback, asynchronously
+ /// </summary>
private async void PrepareAsync()
{
DbgPort.D("Prepare player");
if (playerInstance.State == PlayerState.Ready)
{
- duration = playerInstance.StreamInfo.GetDuration();
+ sourceDuration = playerInstance.StreamInfo.GetDuration();
SetRemainTime();
// If you don't want to play automatically whenever VideoPlayer is opened, remove below line.
// TODO: Remove this later, only for TDC
}
}
+ /// <summary>
+ /// Sets the play time on the control area
+ /// </summary>
+ /// <param name="time"></param>
private void SetPlayTime(int time)
{
int second = (time / 1000) % 60;
PlayTimeSec.Text = string.Format("{0:D2}", second);
}
+ /// <summary>
+ /// Sets the remain time on the control area
+ /// </summary>
private void SetRemainTime()
{
- int second = (duration / 1000) % 60;
- int minute = (duration / (1000 * 60)) % 60;
- int hour = (duration / (1000 * 60 * 60)) % 24;
+ int second = (sourceDuration / 1000) % 60;
+ int minute = (sourceDuration / (1000 * 60)) % 60;
+ int hour = (sourceDuration / (1000 * 60 * 60)) % 24;
RemainTimeHr.Text = string.Format("{0:D2}", hour);
RemainTimeMin.Text = string.Format("{0:D2}", minute);
RemainTimeSec.Text = string.Format("{0:D2}", second);
}
+ /// <summary>
+ /// A method for initializing page when the page is appeared
+ /// </summary>
protected override void InitializePage()
{
DbgPort.D("Initialize Page");
GrabRemoteKeys();
}
+ /// <summary>
+ /// Hide the control area
+ /// </summary>
+ /// <returns></returns>
private Func<bool> HideControlAreaHandler()
{
- return delegate()
+ return delegate ()
{
SetControlAreaState(ControlAreaState.HIDE);
};
}
+ /// <summary>
+ /// A method for finalizing page when the page is disappeared
+ /// </summary>
protected override void FinalizePage()
{
DbgPort.D("Finalize Page");
UngrabRemoteKeys();
}
+ /// <summary>
+ /// Starts or resumes playback
+ /// </summary>
private void PlayVideo()
{
DbgPort.D("ElmSharp.Window is activated");
VideoTabViewModelLocator.ViewModel.SetPlayedAt(CurrentVideo);
}
+ /// <summary>
+ /// Initialize the font size for the player
+ /// </summary>
private void InitializeFontSize()
{
int fontSize44 = SizeUtils.GetFontSize(44);
NumText.On<Tizen>().SetFontWeight(FontWeight.Light);
}
+ /// <summary>
+ /// Initialize control buttons for the player
+ /// </summary>
private void InitializeButtons()
{
MediaHubButton[] buttons = new MediaHubButton[6] { PreviousBtn, RewindBtn, PausePlayBtn, ForwardBtn, NextBtn, OptionBtn };
}
}
+ /// <summary>
+ /// This method is called when previous button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private async void PreviousBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
progress.Progress = 0.0;
}
+ /// <summary>
+ /// This method is called when rewind button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void RewindBtnClicked(object sender, EventArgs e)
{
PlayBackForwardIndex = 0;
}
}
+ /// <summary>
+ /// This method is called when pause/play button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void PausePlayBtnClicked(object sender, EventArgs e)
{
if (SpeedInfo.Opacity == 1)
}
}
+ /// <summary>
+ /// This method is called when forward button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void ForwardBtnClicked(object sender, EventArgs e)
{
PlayBackRewindIndex = 0;
}
}
+ /// <summary>
+ /// This method is called when next button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private async void NextBtnClicked(object sender, EventArgs e)
{
if (ControlArea.Opacity == 0)
try
{
- await playerInstance.SetPlayPositionAsync(duration - 500, true);
+ await playerInstance.SetPlayPositionAsync(sourceDuration - 500, true);
}
catch (Exception err)
{
progress.Progress = 1.0;
}
+ /// <summary>
+ /// A method for running hide animation
+ /// </summary>
public override void RunHideAnimation()
{
if (SpeedInfo.Opacity == 1)
TitleLabel.FadeTo(0, 667, Easing.CubicInOut);
}
+ /// <summary>
+ /// A method for running show animation
+ /// </summary>
public override void RunShowAnimation()
{
GradientDim.Opacity = 0;
namespace TVMediaHub.Tizen.Views
{
/// <summary>
- /// @TODO: Comment
+ /// A custom ContentPage for displaying the video tab
/// </summary>
public partial class VideoTab : ContentPageEx
{
+ /// <summary>
+ /// The flag whether content is ready
+ /// </summary>
private bool IsContentReady = false;
+
/// <summary>
/// Identifies the ItemsSource bindable property
/// </summary>
set { SetValue(ItemsSourceProperty, value); }
}
+ /// <summary>
+ /// Identifies the GetInformationCommand bindable property
+ /// </summary>
public static readonly BindableProperty GetInformationsCommandProperty = BindableProperty.Create("GetInformationsCommand", typeof(ICommand), typeof(VideoTab), default(ICommand));
+ /// <summary>
+ /// Gets or sets GetInformation Command
+ /// </summary>
public ICommand GetInformationsCommand
{
get { return (ICommand)GetValue(GetInformationsCommandProperty); }
set { SetValue(GetInformationsCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the IsDeleteStatus bindable property
+ /// </summary>
public static readonly BindableProperty IsDeleteStatusProperty = BindableProperty.Create("IsDeleteStatus", typeof(bool), typeof(VideoTab), false);
/// <summary>
set { SetValue(ChangeSortOptionCommandProperty, value); }
}
+ /// <summary>
+ /// Identifies the OnClickCommand bindable property
+ /// </summary>
public static readonly BindableProperty OnClickCommandProperty = BindableProperty.Create("OnClickCommand", typeof(ICommand), typeof(VideoItem), default(ICommand));
+
+ /// <summary>
+ /// Gets or sets OnClick Command
+ /// </summary>
public ICommand OnClickCommand
{
get
}
}
+ /// <summary>
+ /// A list of bottom buttons
+ /// </summary>
private List<KeyValuePair<double, Button>> BottomButtonList;
+ /// <summary>
+ /// A constructor
+ /// </summary>
public VideoTab()
{
BindingContext = VideoTabViewModelLocator.ViewModel;
InitializeData();
InitializeSize();
InitializeFooter();
- ItemsSource.CollectionChanged += ItemsSource_CollectionChanged;
+ ItemsSource.CollectionChanged += ItemsSourceCollectionChanged;
}
+ /// <summary>
+ /// Initialize the data that is used in this class
+ /// </summary>
private void InitializeData()
{
BottomButtonList = new List<KeyValuePair<double, Button>>();
}
+ /// <summary>
+ /// Initialize the size that is used in this class
+ /// </summary>
private void InitializeSize()
{
VideoTabList.Padding = new Thickness(SizeUtils.GetWidthSize(96), SizeUtils.GetWidthSize(0));
LabelNoContents.FontSize = SizeUtils.GetFontSize(28);
}
+ /// <summary>
+ /// Initialize elements on footer area
+ /// </summary>
private void InitializeFooter()
{
-
FooterNormal.OnDropdownSourceItemSelected += OnSourceChanged;
FooterNormal.OnDropdownSortItemSelected += OnSortOptionChanged;
FooterDelete.CancelButtonEvent += OnCancelClicked;
}
+ /// <summary>
+ /// A method for initializing page when the page is appeared
+ /// </summary>
protected override void InitializePage()
{
if (IsContentReady == false)
}
}
+ /// <summary>
+ /// A method for finalizing page when the page is disappeared
+ /// </summary>
protected override void FinalizePage()
{
/*
*/
}
- private void ItemsSource_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+ /// <summary>
+ /// Occurs when an item is added, removed, changed, moved, or the entire list is refreshed.
+ /// </summary>
+ /// <param name="sender">The object that raised the event</param>
+ /// <param name="e">Information about the event</param>
+ private void ItemsSourceCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
if (e.Action.ToString().Equals("Add"))
{
}
}
+ /// <summary>
+ /// Sets the focust chain on footer area
+ /// </summary>
+ /// <param name="scrollX">The current X position of the scroll</param>
private void SetFooterFocusChain(double scrollX)
{
var Padding = SizeUtils.GetWidthSize(96);
}
}
+ /// <summary>
+ /// Moves the scroller to the given target
+ /// </summary>
+ /// <param name="targetX">The given target</param>
+ /// <param name="targetWidth">The width of the given target</param>
+ /// <param name="padding">The padding of the given target</param>
private void ScrollToTarget(double targetX, int targetWidth, int padding)
{
var ScrollX = VideoTabScrollView.ScrollX;
}
}
+ /// <summary>
+ /// This method is called when cancel button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void OnCancelClicked(object sender, EventArgs e)
{
ChangeTabStatusCommand?.Execute("");
SetFooterFocusChain(VideoTabScrollView.ScrollX);
}
+ /// <summary>
+ /// This method is called when SelectAll button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void OnSelectAllClicked(object sender, EventArgs e)
{
-
}
+ /// <summary>
+ /// This method is called when OK button is clicked
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A event's argument</param>
private void OnOKClicked(object sender, EventArgs e)
{
// TODO : Change to delete Content command
SetFooterFocusChain(VideoTabScrollView.ScrollX);
}
+ /// <summary>
+ /// This method is called when Source option is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A SelectedItemChanged event's argument</param>
private void OnSourceChanged(object sender, SelectedItemChangedEventArgs e)
{
// TODO : Source Change
}
+ /// <summary>
+ /// This method is called when Sort option is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A SelectedItemChanged event's argument</param>
private void OnSortOptionChanged(object sender, SelectedItemChangedEventArgs e)
{
ChangeSortOptionCommand?.Execute(e.SelectedItem);
}
+ /// <summary>
+ /// This method is called when option menu is changed
+ /// </summary>
+ /// <param name="sender">The source of the event</param>
+ /// <param name="e">A SelectedItemChanged event's argument</param>
private void OnOptionSelected(object sender, ContextPopupSelectedEventArgs e)
{
var label = e.Item.Label.ToLower();
}
}
+ /// <summary>
+ /// A method for running hide animation
+ /// </summary>
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public override async void RunHideAnimation()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
+ /// <summary>
+ /// A method for running show animation
+ /// </summary>
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public override async void RunShowAnimation()
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously