Beispiel #1
0
        /**
         * 動画ファイルをロードして、フレームサムネイルを抽出する。
         */
        private async void LoadMediaSource(StorageFile source)
        {
            Ready = false;

            //
            Error.Reset();
            mPlayer.Source = null;
            mPreviewing    = false;
            mTrimmingSlider.Reset();
            mFrameListView.Reset();
            mExtractor.Cancel();
            mFrameListView.ShowCurrentTick = false;

            mComposition.Clips.Clear();
            if (null != source)
            {
                mOriginalSource = MediaSource.CreateFromStorageFile(source);
                var loader = await WvvMediaLoader.LoadAsync(mPlayer, mOriginalSource, this);

                if (loader.Opened)
                {
                    TotalRange = loader.TotalRange;
                    VideoSize  = loader.VideoSize;

                    try
                    {
                        var clip = await MediaClip.CreateFromFileAsync(source);

                        mComposition.Clips.Add(clip.Clone());
                        Ready = true;
                        await mExtractor.ExtractAsync(clip, (s, i, img) =>
                        {
                            mFrameListView.Frames[i] = img;
                        },
                                                      (s, img) =>
                        {
                            mFrameListView.FrameListHeight = mExtractor.ThumbnailHeight;
                            for (int i = 0; i < ThumbnailCount; i++)
                            {
                                mFrameListView.Frames.Add(img);
                            }
                            mFrameListView.ShowCurrentTick = true;
                        });
                    }
                    catch (Exception e)
                    {
                        CmLog.error(e, "WvvTrimmingView.LoadMediaSource: Error");
                        Error.SetError(e);
                    }
                }
                else // not opened.
                {
                    Error.CopyFrom(loader.Error);
                }
            }
        }
Beispiel #2
0
 private void OnUnloaded(object sender, RoutedEventArgs e)
 {
     mPlayer.Error.PropertyChanged -= Error_PropertyChanged;
     mExtractor.Cancel();
     Reset();
 }