summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJH Choi <jjie.choi@samsung.com>2017-09-19 07:29:27 (GMT)
committerJH Choi <jjie.choi@samsung.com>2017-09-19 07:31:23 (GMT)
commit83f5555c218710daf057e08e9e6e42032ccefa1d (patch)
treecaeead393fab19d70af23995591455f2c05ecaae
parent87c5c7cf92a12ea01664d37c66edf3816ca8321d (diff)
downloadvideoplayer-tizen.zip
videoplayer-tizen.tar.gz
videoplayer-tizen.tar.bz2
Change-Id: Ia9ff45aeaf21e968a9bd2f4e5e6df12c462a8626 Signed-off-by: JH Choi <jjie.choi@samsung.com>
-rwxr-xr-xVideoPlayerLite/VideoPlayerLite.Android/Renderers/MediaRenderingViewRenderer.cs34
-rwxr-xr-xVideoPlayerLite/VideoPlayerLite/Models/MediaItemProvider.cs55
-rwxr-xr-xVideoPlayerLite/VideoPlayerLite/ViewModels/PlayerPageViewModel.cs43
-rwxr-xr-xVideoPlayerLite/VideoPlayerLite/Views/MediaRenderingView.xaml.cs35
4 files changed, 149 insertions, 18 deletions
diff --git a/VideoPlayerLite/VideoPlayerLite.Android/Renderers/MediaRenderingViewRenderer.cs b/VideoPlayerLite/VideoPlayerLite.Android/Renderers/MediaRenderingViewRenderer.cs
index 51e2322..092ac45 100755
--- a/VideoPlayerLite/VideoPlayerLite.Android/Renderers/MediaRenderingViewRenderer.cs
+++ b/VideoPlayerLite/VideoPlayerLite.Android/Renderers/MediaRenderingViewRenderer.cs
@@ -26,11 +26,24 @@ using Android.Util;
[assembly: ExportRenderer(typeof(MediaRenderingView), typeof(MediaRenderingViewRenderer))]
namespace VideoPlayerLite.Android
{
+ /// <summary>
+ /// MediaRenderingViewRenderer implements the VideoView Custom Renderer on the Android Platform.
+ /// </summary>
public class MediaRenderingViewRenderer : ViewRenderer<MediaRenderingView, VideoView>
{
private static readonly string TAG = "VideoViewRenderer";
+ /// <summary>
+ /// Timer for updating the playing position on the video player UI.
+ /// </summary>
private Timer playPositionTimer;
+ /// <summary>
+ /// When the Element, which is created on the Xamarin Forms, is changed, this method is going to be invoked.
+ /// If the control is null, assign Android VideoView to the Control property with the SetNativeControl method.
+ /// If OldElement is not null, unsubscribe VideoViewCompletion event from event handler.
+ /// If NewElement is not null, subscribe VideoViewCompletion event to the event handler.
+ /// </summary>
+ /// <param name="e">Data of the event</param>
protected override void OnElementChanged(ElementChangedEventArgs<MediaRenderingView> e)
{
base.OnElementChanged(e);
@@ -40,7 +53,6 @@ namespace VideoPlayerLite.Android
SetNativeControl(new VideoView(Context));
}
- // OldElement 와 NewElement 의 순서를 바꿀것. 둘 다 있는 경우 문제 해결
if (e.OldElement != null)
{
Control.Completion -= VideoViewCompletion;
@@ -54,6 +66,13 @@ namespace VideoPlayerLite.Android
}
}
+ /// <summary>
+ /// OnElementPropertyChanged method is called whenever any bindable properties in the MediaRenderingView change MediaRenderingView.
+ /// PlayingItem property will change VideoPlayer to start with new video item.
+ /// MediaRenderingView.PlayerStatus property will change when VideoPlayer receive UI control event.
+ /// </summary>
+ /// <param name="sender">The object what got the event</param>
+ /// <param name="e">Data of the event</param>
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
@@ -95,11 +114,20 @@ namespace VideoPlayerLite.Android
}
}
+ /// <summary>
+ /// It is called when playing is completed. Then, this method changes player status of mediaRendering view to the stopped status
+ /// </summary>
+ /// <param name="sender">The object what got the event</param>
+ /// <param name="e">Data of the event</param>
private void VideoViewCompletion(object sender, System.EventArgs e)
{
((IElementController)Element).SetValueFromRenderer(MediaRenderingView.CurrentStatusProperty, PlayerStatus.Stopped);
}
+ /// <summary>
+ /// Creates new timer for updating plyaing position at VideoPlayer
+ /// Timer gets current playing position from Android VideoView every 250ms and updates the position.
+ /// </summary>
private void StartTimer()
{
if (playPositionTimer != null)
@@ -137,7 +165,9 @@ namespace VideoPlayerLite.Android
});
}, null, 0, 250);
}
-
+ /// <summary>
+ /// Destroys the playing position update timer
+ /// </summary>
private void StopTimer()
{
playPositionTimer?.Dispose();
diff --git a/VideoPlayerLite/VideoPlayerLite/Models/MediaItemProvider.cs b/VideoPlayerLite/VideoPlayerLite/Models/MediaItemProvider.cs
index f60099a..2b41e98 100755
--- a/VideoPlayerLite/VideoPlayerLite/Models/MediaItemProvider.cs
+++ b/VideoPlayerLite/VideoPlayerLite/Models/MediaItemProvider.cs
@@ -22,16 +22,46 @@ using Xamarin.Forms;
namespace VideoPlayerLite.Models
{
+ /// <summary>
+ /// Use DependencyService to get the IMediaContentAPIs implementation of each native platform
+ /// Provide video contents information for the ViewModel
+ /// </summary>
+ /// <remarks>
+ /// Please refer to Xamarin Dependency Service
+ /// https://developer.xamarin.com/guides/xamarin-forms/dependency-service/introduction/
+ /// </remarks>
public sealed class MediaItemProvider
{
+ /// <summary>
+ /// Instance for lazy initialization of MediaItemProvider.
+ /// </summary>
private static readonly Lazy<MediaItemProvider> lazy = new Lazy<MediaItemProvider>(() => new MediaItemProvider());
+ /// <summary>
+ /// A Media Item Provider class instance which provides Media Items.
+ /// When it is called for the first time, MeidaItemProvider will be created.
+ /// </summary>
public static MediaItemProvider Instance { get => lazy.Value; }
+ /// <summary>
+ /// Instance of IMediaContentAPIs for get the implementation of each platform.
+ /// </summary>
private static IMediaContentAPIs mediaContentAPIs;
+ /// <summary>
+ /// A List of the Video item
+ /// </summary>
private IEnumerable<MediaItem> itemList;
+ /// <summary>
+ /// Media information of the video item. It is the selected video item at Library view and it is the video item that is currently being played.
+ /// </summary>
private MediaItem selectedItem;
+ /// <summary>
+ /// A selected item's index in the itemList.
+ /// </summary>
private int selectedItemIndex;
-
+ /// <summary>
+ /// MediaItemprovider Constroctor
+ /// A Constructor which will initialize the MediaContentAPIs instance.
+ /// </summary>
private MediaItemProvider()
{
if (DependencyService.Get<IMediaContentAPIs>() != null)
@@ -39,9 +69,13 @@ namespace VideoPlayerLite.Models
mediaContentAPIs = DependencyService.Get<IMediaContentAPIs>();
}
}
-
+ /// <summary>
+ /// Gets video item list
+ /// </summary>
public IEnumerable<MediaItem> ItemList { get => itemList; }
-
+ /// <summary>
+ /// A property indicates a selected media item. If the SelectedItem is set, the selectedItemIndex will be updated too.
+ /// </summary>
public MediaItem SelectedItem
{
get => selectedItem;
@@ -51,7 +85,10 @@ namespace VideoPlayerLite.Models
selectedItemIndex = itemList.ToList().IndexOf(selectedItem);
}
}
-
+ /// <summary>
+ /// Changes SelectedItem to the item at the next index of the current item in the itemList.
+ /// </summary>
+ /// <returns>Returns changed selectedItem</returns>
public MediaItem MoveToNext()
{
selectedItemIndex++;
@@ -63,7 +100,10 @@ namespace VideoPlayerLite.Models
return selectedItem = itemList.ElementAt(selectedItemIndex);
}
-
+ /// <summary>
+ /// Changes SelectedItem to the item at the previous index of the current item in the itemList.
+ /// </summary>
+ /// <returns>Returns changed selectedItem</returns>
public MediaItem MoveToPrev()
{
selectedItemIndex--;
@@ -75,7 +115,10 @@ namespace VideoPlayerLite.Models
return selectedItem = itemList.ElementAt(selectedItemIndex);
}
-
+ /// <summary>
+ /// Gets a list of all video items from the native platform.
+ /// </summary>
+ /// <returns>Returns video item list</returns>
public async Task Update()
{
itemList = await mediaContentAPIs.GetAllVideoItemListAsync();
diff --git a/VideoPlayerLite/VideoPlayerLite/ViewModels/PlayerPageViewModel.cs b/VideoPlayerLite/VideoPlayerLite/ViewModels/PlayerPageViewModel.cs
index c727d67..5ac8888 100755
--- a/VideoPlayerLite/VideoPlayerLite/ViewModels/PlayerPageViewModel.cs
+++ b/VideoPlayerLite/VideoPlayerLite/ViewModels/PlayerPageViewModel.cs
@@ -20,13 +20,21 @@ using Xamarin.Forms;
namespace VideoPlayerLite.ViewModels
{
+ /// <summary>
+ /// A VideModel for the PlayerPageView which manages Player controls and displaying information of a playing media item.
+ /// </summary>
public class PlayerPageViewModel : ViewModelBase
{
private static readonly string NEXT_BUTTON = "Next";
private static readonly string PREV_BUTTON = "Previous";
+ /// <summary>
+ /// MediaItem information of current selected video.
+ /// </summary>
private MediaItem selectedVideo;
-
+ /// <summary>
+ /// A property for the selectedVideo.
+ /// </summary>
public MediaItem SelectedVideo
{
get { return selectedVideo; }
@@ -37,7 +45,13 @@ namespace VideoPlayerLite.ViewModels
}
}
+ /// <summary>
+ /// Playing position of the vidoe item currently being played.
+ /// </summary>
private int currentPosition;
+ /// <summary>
+ /// A property for the currentPosition.
+ /// </summary>
public int CurrentPosition
{
get => currentPosition;
@@ -47,8 +61,13 @@ namespace VideoPlayerLite.ViewModels
OnPropertyChanged();
}
}
-
+ /// <summary>
+ /// Video Player status.
+ /// </summary>
private PlayerStatus currentStatus;
+ /// <summary>
+ /// A property for the playerStatus.
+ /// </summary>
public PlayerStatus CurrentStatus
{
get => currentStatus;
@@ -58,8 +77,13 @@ namespace VideoPlayerLite.ViewModels
OnPropertyChanged();
}
}
-
+ /// <summary>
+ /// Command for the Previous and the Next buttons of the video player controller.
+ /// </summary>
private Command controlButtonCommand;
+ /// <summary>
+ /// A property for the controlButtonCommand.
+ /// </summary>
public Command ControlButtonCommand
{
get => controlButtonCommand;
@@ -69,9 +93,13 @@ namespace VideoPlayerLite.ViewModels
OnPropertyChanged();
}
}
-
+ /// <summary>
+ /// A Command which provides selected video item.
+ /// </summary>
private Command fetchSelectedVideoCommand;
-
+ /// <summary>
+ /// A property for the fetchSelectedVideoCommnad.
+ /// </summary>
public Command FetchSelectedVideoCommand
{
get => fetchSelectedVideoCommand;
@@ -81,7 +109,10 @@ namespace VideoPlayerLite.ViewModels
OnPropertyChanged();
}
}
-
+ /// <summary>
+ /// PlayPageViewModel constructor.
+ /// Initializes the commands such as the PlayerButtonCommand and the FetchSelectedVideoCommand.
+ /// </summary>
public PlayerPageViewModel()
{
ControlButtonCommand = new Command<string>((buttonName) =>
diff --git a/VideoPlayerLite/VideoPlayerLite/Views/MediaRenderingView.xaml.cs b/VideoPlayerLite/VideoPlayerLite/Views/MediaRenderingView.xaml.cs
index 20693bd..1f86b3d 100755
--- a/VideoPlayerLite/VideoPlayerLite/Views/MediaRenderingView.xaml.cs
+++ b/VideoPlayerLite/VideoPlayerLite/Views/MediaRenderingView.xaml.cs
@@ -19,6 +19,9 @@ using VideoPlayerLite.Models;
namespace VideoPlayerLite.Views
{
+ /// <summary>
+ /// An enumeration for the status of the video player
+ /// </summary>
public enum PlayerStatus
{
Playing,
@@ -29,29 +32,53 @@ namespace VideoPlayerLite.Views
public partial class MediaRenderingView : View
{
- // Creating a bindable property named "Items" of type IEnumrable<MediaItem> which is owned by LibraryView and has default value null.
+ /// <summary>
+ /// Creating a bindable property named "Items" of type IEnumrable<MediaItem> which is owned by LibraryView and has the default value of null
+ /// </summary>
public static readonly BindableProperty CurrentVideoProperty = BindableProperty.Create("CurrentVideo", typeof(MediaItem), typeof(MediaRenderingView), null);
+ /// <summary>
+ /// Gets the video item currently being played
+ /// </summary>
public MediaItem CurrentVideo
{
get => (MediaItem)GetValue(CurrentVideoProperty);
}
+ /// <summary>
+ /// Gets the path of the video item currently being played
+ /// </summary>
public string VideoPath { get => CurrentVideo?.Path; }
+ /// <summary>
+ /// Creating a bindable property named "CurrentStatus" of type PlayerStatus
+ /// Default value is PlayerStatus.Stopped
+ /// It is a two-way bindable property
+ /// </summary>
public static readonly BindableProperty CurrentStatusProperty = BindableProperty.Create("CurrentStatus", typeof(PlayerStatus), typeof(MediaRenderingView), PlayerStatus.Stopped, BindingMode.TwoWay);
-
+ /// <summary>
+ /// Gets or sets the current playing status of the video player
+ /// </summary>
public PlayerStatus CurrentStatus
{
get => (PlayerStatus)GetValue(CurrentStatusProperty);
set => SetValue(CurrentStatusProperty, value);
}
-
+ /// <summary>
+ /// Creating a bindable property named "CurrentPosition" of type integer
+ /// Default value is 0
+ /// It only propagates changes from the target to the source
+ /// </summary>
public static readonly BindableProperty CurrentPositionProperty = BindableProperty.Create("CurrentPosition", typeof(int), typeof(MediaRenderingView), 0, BindingMode.OneWayToSource);
+ /// <summary>
+ /// Playing position of the video item currently being played
+ /// </summary>
public int CurrentPosition
{
get => (int)GetValue(CurrentPositionProperty);
}
-
+ /// <summary>
+ /// A MediaRenderingView constructor which will initialize GUI components in the XAML.
+ /// </summary>
public MediaRenderingView()
{
InitializeComponent();