Windows 10のユニバーサルアプリはストアアプリと同様、基本的にストアからインストールをしてくださいという形になっている。そのためアプリ自体をビルドして出てきたファイルを実行しようとしてもAppContainerから実行されてないというようなエラーが出て実行できない。これを回避し自作ユニバーサルアプリを自分の環境で使いたい場合、アプリをインストールしてから実行する必要がある。というわけで自作ユニバーサルアプリのインストール方法のメモ。表示言語が英語での操作でやっているのでそこらは適宜読み換え。 まず注意点。ユニバーサルアプリをストアを介さずにインストールできるようにするのはリスクを抱えることになる。基本審査を行うストアを介してインストールされるべきアプリが、ストア以外の入手先もOKということになってしまうので。というわけでインストールして使うのは自作アプリに絞ること。どっかから拾ってきたアプリでこの方法を実行しないこと。
if (!File.Exists(src)) { System.ArgumentException argEx = new System.ArgumentException("Source file not found"); throw argEx; } AudioVideoFile avFile = null; try { avFile = new AudioVideoFile(src); } catch (Exception ex) { System.ArgumentException argEx = new System.ArgumentException(ex.Message); throw argEx; }
// Gets the time for each thumbnail. if (point > avFile.Duration.TotalSeconds) { Console.WriteLine(avFile.Duration.TotalSeconds); System.ArgumentException argEx = new System.ArgumentException("Over a duration"); throw argEx; }
// Create ThumbnailGenerator object to get thumbs from AudioVideoFile Microsoft.Expression.Encoder.ThumbnailGenerator generator = avFile.CreateThumbnailGenerator(avFile.VideoStreams[0].VideoSize);
// Gets image based on timing thumbnail = generator.CreateThumbnail(TimeSpan.FromSeconds(point));
if (!File.Exists(src)) { System.ArgumentException argEx = new System.ArgumentException("Source file not found"); throw argEx; } AudioVideoFile avFile = null; try { avFile = new AudioVideoFile(src); } catch (Exception ex) { System.ArgumentException argEx = new System.ArgumentException(ex.Message); throw argEx; }
// Gets the time for each thumbnail. if (point > avFile.Duration.TotalSeconds) { Console.WriteLine(avFile.Duration.TotalSeconds); System.ArgumentException argEx = new System.ArgumentException("Over a duration"); throw argEx; }
// Create ThumbnailGenerator object to get thumbs from AudioVideoFile Microsoft.Expression.Encoder.ThumbnailGenerator generator = avFile.CreateThumbnailGenerator(avFile.VideoStreams[0].VideoSize);
// Gets image based on timing thumbnail = generator.CreateThumbnail(TimeSpan.FromSeconds(point));
generator.Dispose(); return thumbnail; } } }
Booで上記のコードを書きかえる
namespace BooThumbnailGenerator
import System import System.Drawing import System.Drawing.Imaging import System.IO import Microsoft.Expression.Encoder
public static class ThumbnailGenerator: public def SaveThumbnail(src as string, outputName as string, point as double) as void: thumbnail = GetThumbnail(src, point) as Bitmap
// sets thumbnail name unique and saves thumbnail.Save(outputName, ImageFormat.Jpeg)
thumbnail.Dispose()
public def GetThumbnail(src as string, point as double) as Bitmap: thumbnail as Bitmap
if not File.Exists(src): raise "Source file not found" avFile = null as AudioVideoFile try: avFile = AudioVideoFile(src) except e: raise e
// Gets the time for each thumbnail. if point > avFile.Duration.TotalSeconds: print(avFile.Duration.TotalSeconds) raise "Over a duration"
// Create ThumbnailGenerator object to get thumbs from AudioVideoFile generator = avFile.CreateThumbnailGenerator(avFile.VideoStreams[0].VideoSize) as Microsoft.Expression.Encoder.ThumbnailGenerator
// Gets image based on timing thumbnail = generator.CreateThumbnail(TimeSpan.FromSeconds(point))
if (!File.Exists(src)) { System.ArgumentException argEx = new System.ArgumentException("Source file not found"); throw argEx; } AudioVideoFile avFile = null; try { avFile = new AudioVideoFile(src); } catch (Exception ex) { System.ArgumentException argEx = new System.ArgumentException(ex.Message); throw argEx; }
// Gets the time for each thumbnail. if (point > avFile.Duration.TotalSeconds) { Console.WriteLine(avFile.Duration.TotalSeconds); System.ArgumentException argEx = new System.ArgumentException("Over a duration"); throw argEx; }
// Create ThumbnailGenerator object to get thumbs from AudioVideoFile Microsoft.Expression.Encoder.ThumbnailGenerator generator = avFile.CreateThumbnailGenerator(avFile.VideoStreams[0].VideoSize);
// Gets image based on timing thumbnail = generator.CreateThumbnail(TimeSpan.FromSeconds(point));
import System from System.Drawing import * from System.IO import * from System.Threading import * from System.Windows import *
from Microsoft.Expression.Encoder.ScreenCapture import * from Microsoft.Expression.Encoder.Devices import * from Microsoft.Expression.Encoder.Profiles import * from System.Windows.Interop import * from System.Runtime.InteropServices import * from WindowServices import WindowsServices
if (x0 < 0) or (y0 < 0) or (width < 0) or (height < 0): return self.tWindow.Left = x0 self.tWindow.Top = y0 self.tWindow.Width = width self.tWindow.Height = height self.tWindow.WindowState = System.Windows.WindowState.Normal
def OnClose(self, sender, e): if (self.job.Status == RecordStatus.Running): result = System.Windows.MessageBox.Show("Capturing in Progress. Are You Sure You Want To Quit?", "Capturing", MessageBoxButton.YesNo) if (result == MessageBoxResult.No): e.Cancel = True return self.job.Stop() self.job.Dispose() Application.Current.Shutdown()