From a60a1d0ff05d21ef711508efcc1c4445eada5a8f Mon Sep 17 00:00:00 2001 From: Hyerim Kim Date: Thu, 14 Sep 2017 17:42:09 +0900 Subject: Adds comments. Change-Id: If007d716aa2c6befdf3325313b5de47a2c0da63c Signed-off-by: Hyerim Kim --- .../Port/MediaContentPort.cs | 28 ++++++++++++++++++++++ .../VideoPlayerLite/Models/DurationConverter.cs | 22 +++++++++++++++++ .../VideoPlayerLite/ViewModels/ItemViewModel.cs | 15 +++++++++--- .../VideoPlayerLite/ViewModels/ViewModelBase.cs | 12 ++++++++++ .../VideoPlayerLite/Views/PlayerButton.xaml.cs | 19 +++++++++++++++ 5 files changed, 93 insertions(+), 3 deletions(-) diff --git a/VideoPlayerLite/VideoPlayerLite.Android/Port/MediaContentPort.cs b/VideoPlayerLite/VideoPlayerLite.Android/Port/MediaContentPort.cs index 8b51c8a..bcc19fb 100755 --- a/VideoPlayerLite/VideoPlayerLite.Android/Port/MediaContentPort.cs +++ b/VideoPlayerLite/VideoPlayerLite.Android/Port/MediaContentPort.cs @@ -30,6 +30,11 @@ using VideoPlayerLite.Models; namespace VideoPlayerLite.Android.Port { + /// + /// A class for implementing the IMediaContentAPIs interface. + /// Gets the video items from the device and creates the thumbnail of the item if needed. + /// Returns the list of MediaItem that is created by the redefinition of the video item. + /// public class MediaContentPort : IMediaContentAPIs { private string[] videoProjection = @@ -39,6 +44,11 @@ namespace VideoPlayerLite.Android.Port MediaStore.Video.VideoColumns.Duration }; + /// + /// Gets all the video items stored in the device. + /// Creates the list of MediaItem that is redefined from the video items. + /// + /// A list of the MediaItem. public async Task> GetAllVideoItemListAsync() { var itemList = new List(); @@ -72,6 +82,12 @@ namespace VideoPlayerLite.Android.Port return itemList; } + /// + /// Gets the path of the specific media content. + /// + /// The URI to be used to query. + /// The id of a specific media to get the path. + /// private string GetMediaContentPath(global::Android.Net.Uri uri, string documentId) { var path = String.Empty; @@ -86,6 +102,11 @@ namespace VideoPlayerLite.Android.Port return path; } + /// + /// Creates the thumbnail of video item and stores it to a file. + /// + /// A path of the video file to create the thumbnail. + /// A path of the created thumbnail. private async Task SaveThumbnailToFileAsync(string path) { return await Task.Run(() => @@ -107,6 +128,13 @@ namespace VideoPlayerLite.Android.Port }); } + /// + /// Stores the created thumbnail to a file. + /// The path to store refers to the path of the video item. + /// + /// The path of the video item to create the thumbnail. + /// The created thumbnail. + /// The path of the stored file. private string SaveToFile(string path, Bitmap bitmap) { var thumbnailPath = System.IO.Path.ChangeExtension(path, ".jpeg"); diff --git a/VideoPlayerLite/VideoPlayerLite/Models/DurationConverter.cs b/VideoPlayerLite/VideoPlayerLite/Models/DurationConverter.cs index 4a4335e..8c4a54f 100755 --- a/VideoPlayerLite/VideoPlayerLite/Models/DurationConverter.cs +++ b/VideoPlayerLite/VideoPlayerLite/Models/DurationConverter.cs @@ -20,13 +20,35 @@ using System; namespace VideoPlayerLite.Models { + /// + /// A custom converter made by inherited the IValueConverter interface. + /// public class DurationConverter : IValueConverter { + /// + /// Converts a value from the binding source to the binding target. + /// In this project, converting the current position of the video being played and the duration to a specific string format, + /// and the converted value is provided to the binding target. + /// + /// The value produced by the binding source. + /// The type of the binding target property. + /// The converter parameter to be used. + /// The culture to be used in the converter. + /// A converted value. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return TimeSpan.FromMilliseconds((int)value).ToString("mm':'ss"); } + /// + /// Converts a value from the binding target to the binding source. + /// In this project, this method is not used. + /// + /// The value that is producted by the binding target. + /// The type to convert to. + /// The converter parameter to be used. + /// The culture to be used in the converter. + /// A converted value. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); diff --git a/VideoPlayerLite/VideoPlayerLite/ViewModels/ItemViewModel.cs b/VideoPlayerLite/VideoPlayerLite/ViewModels/ItemViewModel.cs index b12048d..6e6fcd4 100755 --- a/VideoPlayerLite/VideoPlayerLite/ViewModels/ItemViewModel.cs +++ b/VideoPlayerLite/VideoPlayerLite/ViewModels/ItemViewModel.cs @@ -19,6 +19,9 @@ using Xamarin.Forms; namespace VideoPlayerLite.ViewModels { + /// + /// A viewmodel for item view that is displayed in the library page + /// class ItemViewModel : ViewModelBase { @@ -34,11 +37,11 @@ namespace VideoPlayerLite.ViewModels } } - - // When creating a bindable property, the property must have getter as public. - // To make a public getter, it has to be defined explicitly. private Command setNewVideoCommand; + /// + /// A property for command to be executed when the item in the library page is selected. + /// public Command SetNewVideoCommand { get => setNewVideoCommand; @@ -49,6 +52,12 @@ namespace VideoPlayerLite.ViewModels } } + /// + /// A constructor of the ItemViewModel class + /// Stores the parameter to the VideoItem in this class. + /// Implements the SetNewVideoCommand. + /// + /// The MediaItem that is passed when the ItemView is created. public ItemViewModel(MediaItem item) { VideoItem = item; diff --git a/VideoPlayerLite/VideoPlayerLite/ViewModels/ViewModelBase.cs b/VideoPlayerLite/VideoPlayerLite/ViewModels/ViewModelBase.cs index a6e7b1e..a868870 100755 --- a/VideoPlayerLite/VideoPlayerLite/ViewModels/ViewModelBase.cs +++ b/VideoPlayerLite/VideoPlayerLite/ViewModels/ViewModelBase.cs @@ -19,10 +19,22 @@ using System.Runtime.CompilerServices; namespace VideoPlayerLite.ViewModels { + /// + /// This class is the base class for the other viewmodels. + /// Other viewmodels in this project inherit this class + /// and can use OnPropertyChanged method to invoke PropertyChanged event. + /// public class ViewModelBase : INotifyPropertyChanged { + /// + /// An event that is triggered when property is changed + /// public event PropertyChangedEventHandler PropertyChanged; + /// + /// A method for invoking PropertyChanged event + /// + /// The name of property that is changed. The default value is null. protected void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); diff --git a/VideoPlayerLite/VideoPlayerLite/Views/PlayerButton.xaml.cs b/VideoPlayerLite/VideoPlayerLite/Views/PlayerButton.xaml.cs index 60af409..b7d09e7 100755 --- a/VideoPlayerLite/VideoPlayerLite/Views/PlayerButton.xaml.cs +++ b/VideoPlayerLite/VideoPlayerLite/Views/PlayerButton.xaml.cs @@ -19,10 +19,19 @@ using Xamarin.Forms; namespace VideoPlayerLite.Views { + /// + /// A custom layout for displaying the play/pause, previous and next buttons in the player page. + /// public partial class PlayerButton : RelativeLayout { + /// + /// An event to be invoked to the PlayerPage when the button is clicked. + /// public event EventHandler Clicked; + /// + /// A string property sets to or gets from the source of Icon image. + /// public string ButtonImage { get => Icon.Source.ToString(); @@ -33,12 +42,19 @@ namespace VideoPlayerLite.Views } } + /// + /// A string property sets to or gets from the CommandParameter defined in the PlayerButton.xaml. + /// public string ButtonName { get => FocusButton.CommandParameter.ToString(); set => FocusButton.CommandParameter = value; } + /// + /// A constructor of the PlayerButton class + /// Implements the click event of button in order to invoke the event to the PlayerPage. + /// public PlayerButton() { InitializeComponent(); @@ -46,6 +62,9 @@ namespace VideoPlayerLite.Views FocusButton.Clicked += (s, e) => Clicked?.Invoke(this, EventArgs.Empty); } + /// + /// Focuses to the button object of PlayerButton. + /// public void SetFocus() { FocusButton.Focus(); -- cgit v1.2.3