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
13
/**********************************************************************
* VLC for WinRT
**********************************************************************
* Copyright © 2013-2014 VideoLAN and Authors
*
* Licensed under GPLv2+ and MPLv2
* Refer to COPYING file of the official project for license
**********************************************************************/
using Windows.Storage.Pickers;
using Windows.UI.Xaml.Controls;
using VLC.Model.Video;
using System;
using VLC.ViewModels;
using VLC.Utils;
namespace VLC.Commands.VideoLibrary
{
public class ChangeVideoCoverCommand : AlwaysExecutableCommand
{
public override async void Execute(object parameter)
{
var video = parameter as VideoItem;
if (video == 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,
FileTypeFilter = { ".jpg", ".jpeg", ".png", ".gif" },
CommitButtonText = "Select image cover" // TODO: needs translation
};
// 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);
video.InitializeVideoImage();
}
}
}
Loading