diff options
author | Hyerim Kim <rimi.kim@samsung.com> | 2017-09-14 17:42:09 +0900 |
---|---|---|
committer | Hyerim Kim <rimi.kim@samsung.com> | 2017-09-15 10:32:00 +0900 |
commit | a60a1d0ff05d21ef711508efcc1c4445eada5a8f (patch) | |
tree | a2f15fed36fb92fe84b8ecb1b2b99067dbb41d13 | |
parent | 7ec455987b8504fce5658f28638512ea8f4c9817 (diff) | |
download | videoplayer-a60a1d0ff05d21ef711508efcc1c4445eada5a8f.tar.gz videoplayer-a60a1d0ff05d21ef711508efcc1c4445eada5a8f.tar.bz2 videoplayer-a60a1d0ff05d21ef711508efcc1c4445eada5a8f.zip |
Adds comments.
Change-Id: If007d716aa2c6befdf3325313b5de47a2c0da63c
Signed-off-by: Hyerim Kim <rimi.kim@samsung.com>
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 { + /// <summary> + /// 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. + /// </summary> public class MediaContentPort : IMediaContentAPIs { private string[] videoProjection = @@ -39,6 +44,11 @@ namespace VideoPlayerLite.Android.Port MediaStore.Video.VideoColumns.Duration }; + /// <summary> + /// Gets all the video items stored in the device. + /// Creates the list of MediaItem that is redefined from the video items. + /// </summary> + /// <returns>A list of the MediaItem.</returns> public async Task<IEnumerable<MediaItem>> GetAllVideoItemListAsync() { var itemList = new List<MediaItem>(); @@ -72,6 +82,12 @@ namespace VideoPlayerLite.Android.Port return itemList; } + /// <summary> + /// Gets the path of the specific media content. + /// </summary> + /// <param name="uri">The URI to be used to query.</param> + /// <param name="documentId">The id of a specific media to get the path.</param> + /// <returns></returns> private string GetMediaContentPath(global::Android.Net.Uri uri, string documentId) { var path = String.Empty; @@ -86,6 +102,11 @@ namespace VideoPlayerLite.Android.Port return path; } + /// <summary> + /// Creates the thumbnail of video item and stores it to a file. + /// </summary> + /// <param name="path">A path of the video file to create the thumbnail.</param> + /// <returns>A path of the created thumbnail.</returns> private async Task<string> SaveThumbnailToFileAsync(string path) { return await Task.Run(() => @@ -107,6 +128,13 @@ namespace VideoPlayerLite.Android.Port }); } + /// <summary> + /// Stores the created thumbnail to a file. + /// The path to store refers to the path of the video item. + /// </summary> + /// <param name="path">The path of the video item to create the thumbnail.</param> + /// <param name="bitmap">The created thumbnail.</param> + /// <returns>The path of the stored file.</returns> 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 { + /// <summary> + /// A custom converter made by inherited the IValueConverter interface. + /// </summary> public class DurationConverter : IValueConverter { + /// <summary> + /// 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. + /// </summary> + /// <param name="value">The value produced by the binding source.</param> + /// <param name="targetType">The type of the binding target property.</param> + /// <param name="parameter">The converter parameter to be used.</param> + /// <param name="culture">The culture to be used in the converter.</param> + /// <returns>A converted value.</returns> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return TimeSpan.FromMilliseconds((int)value).ToString("mm':'ss"); } + /// <summary> + /// Converts a value from the binding target to the binding source. + /// In this project, this method is not used. + /// </summary> + /// <param name="value">The value that is producted by the binding target.</param> + /// <param name="targetType">The type to convert to.</param> + /// <param name="parameter">The converter parameter to be used.</param> + /// <param name="culture">The culture to be used in the converter.</param> + /// <returns>A converted value.</returns> 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 { + /// <summary> + /// A viewmodel for item view that is displayed in the library page + /// </summary> 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; + /// <summary> + /// A property for command to be executed when the item in the library page is selected. + /// </summary> public Command SetNewVideoCommand { get => setNewVideoCommand; @@ -49,6 +52,12 @@ namespace VideoPlayerLite.ViewModels } } + /// <summary> + /// A constructor of the ItemViewModel class + /// Stores the parameter to the VideoItem in this class. + /// Implements the SetNewVideoCommand. + /// </summary> + /// <param name="item">The MediaItem that is passed when the ItemView is created.</param> 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 { + /// <summary> + /// 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. + /// </summary> public class ViewModelBase : INotifyPropertyChanged { + /// <summary> + /// An event that is triggered when property is changed + /// </summary> public event PropertyChangedEventHandler PropertyChanged; + /// <summary> + /// A method for invoking PropertyChanged event + /// </summary> + /// <param name="propertyName">The name of property that is changed. The default value is null.</param> 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 { + /// <summary> + /// A custom layout for displaying the play/pause, previous and next buttons in the player page. + /// </summary> public partial class PlayerButton : RelativeLayout { + /// <summary> + /// An event to be invoked to the PlayerPage when the button is clicked. + /// </summary> public event EventHandler Clicked; + /// <summary> + /// A string property sets to or gets from the source of Icon image. + /// </summary> public string ButtonImage { get => Icon.Source.ToString(); @@ -33,12 +42,19 @@ namespace VideoPlayerLite.Views } } + /// <summary> + /// A string property sets to or gets from the CommandParameter defined in the PlayerButton.xaml. + /// </summary> public string ButtonName { get => FocusButton.CommandParameter.ToString(); set => FocusButton.CommandParameter = value; } + /// <summary> + /// A constructor of the PlayerButton class + /// Implements the click event of button in order to invoke the event to the PlayerPage. + /// </summary> public PlayerButton() { InitializeComponent(); @@ -46,6 +62,9 @@ namespace VideoPlayerLite.Views FocusButton.Clicked += (s, e) => Clicked?.Invoke(this, EventArgs.Empty); } + /// <summary> + /// Focuses to the button object of PlayerButton. + /// </summary> public void SetFocus() { FocusButton.Focus(); |