Skip to content
Snippets Groups Projects

Proposed changes for issue #162: Request for custom video cover art

Open Martin Finkel requested to merge mfkl/vlc-winrt:feature/custom-video-cover into master
1 unresolved thread
Files
2
@@ -12,41 +12,42 @@ using Windows.UI.Xaml.Controls;
using VLC.Model.Video;
using System;
using VLC.ViewModels;
using VLC.Model;
using VLC.Utils;
namespace VLC.Commands.VideoLibrary
{
public class ChangeVideoCoverCommand : AlwaysExecutableCommand
{
public async override void Execute(object parameter)
public override async void Execute(object parameter)
{
var video = parameter as VideoItem;
if (video == null)
{
var args = parameter as ItemClickEventArgs;
if(args != null)
if(parameter is ItemClickEventArgs args)
video = args.ClickedItem as VideoItem;
}
if (video == null)
return;
var openPicker = new FileOpenPicker
{
ViewMode = PickerViewMode.Thumbnail,
SuggestedStartLocation = PickerLocationId.VideosLibrary
SuggestedStartLocation = PickerLocationId.VideosLibrary,
FileTypeFilter = { ".jpg", ".jpeg", ".png", ".gif" },
CommitButtonText = "Select image cover" // TODO: needs translation
};
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
openPicker.FileTypeFilter.Add(".gif");
// Windows Phone launches the picker, then freezes the app. We need
// to pick it up again on OnActivated.
var file = await openPicker.PickSingleFileAsync();
if (file == null) return;
var byteArray = await ConvertImage.ConvertImagetoByte(file);
await video.DeleteVideoThumbFile();
await Locator.VideoMetaService.SaveMoviePictureAsync(video, byteArray);
Locator.MediaLibrary.UpdateVideo(video);
await Locator.MediaLibrary.RescanLibrary();
video.InitializeVideoImage();
}
}
}
Loading