コード例 #1
0
        private static void GetMediaInfo(VideoFolderChild vd)
        {
            ShellObject shell = ShellObject.FromParsingName(vd.FilePath);

            try
            {
                vd.Thumbnail = shell.Thumbnail.LargeBitmapSource;
                if (string.IsNullOrEmpty(vd.Duration) || vd.Duration == ApplicationDummyMessage.DurationNotYetLoaded)
                {
                    var duration = shell.Properties.System.Media.Duration;
                    vd.Duration = duration.FormatForDisplay(PropertyDescriptionFormat.ShortTime);
                }
                //if (duration.Value != null)
                //    vd.MaxiProgress = (int)(duration.Value / Math.Pow(10, 7));
            }
            catch (Exception ex)
            {
            }
            var prop = shell.Properties.System.Title.Value;

            if (!string.IsNullOrEmpty(prop) && !prop.Contains("\""))
            {
                vd.MediaTitle = prop;
            }
        }
コード例 #2
0
        public static ObservableCollection <VideoFolder> LoadChildrenFiles(IFolder Parentdir, bool newpath = false)
        {
            ObservableCollection <VideoFolder> Toparent = new ObservableCollection <VideoFolder>();

            List <FileInfo> files = FileExplorerCommonHelper.GetFilesByExtensions(Parentdir.Directory, formats);

            if (files.Count > 0)
            {
                ApplicationService.CreateLastSeenFolder(Parentdir);
                ApplicationService.LoadLastSeenFile(Parentdir);
            }

            for (int i = 0; i < files.Count; i++)
            {
                VideoFolderChild vd;
                PlayedFiles      pdf = (PlayedFiles)LastSeenHelper.GetProgress(Parentdir, files[i].Name);
                vd = new VideoFolderChild(Parentdir, files[i])
                {
                    FileSize = FileExplorerCommonHelper.FileSizeConverter(files[i].Length),
                    FileType = FileType.File
                };
                if (pdf != null)
                {
                    vd.LastPlayedPoisition = pdf;
                }
                else
                {
                    vd.LastPlayedPoisition = new PlayedFiles(files[i].Name);
                }


                Toparent.Add(vd);
            }
            return(Toparent);
        }
コード例 #3
0
        public void CloseMediaPlayer()
        {
            //(IVideoElement as Window).Dispatcher.Invoke(new Action(() =>
            //{
            //IVideoPlayer.MediaPlayer.Close();
            //IsClosing = true;
            //HasSubcribed = false;
            //CreateHelper.SaveLastSeenFile(CurrentVideoItem.ParentDirectory.Directory);
            //currentvideoitem = null;
            //Current = null;
            MediaPlayStopAction();
            MediaPositionTimer.Stop();
            HasSubcribed = false;
            if (CurrentVideoItem != null)
            {
                ApplicationService.SaveLastSeenFile(CurrentVideoItem.ParentDirectory);
            }
            currentvideoitem = null;
            Current          = null;
            if (Playlist.CurrentPlaylist != null)
            {
                Playlist.CurrentPlaylist.SetIsActive(false);
            }


            //}), null);
        }
コード例 #4
0
        private string GetMediaTitle(VideoFolderChild vd)
        {
            ShellObject shell = ShellObject.FromParsingName(vd.FilePath);

            try
            {
                var duration = shell.Properties.System.Media.Duration;
                vd.Duration = duration.FormatForDisplay(PropertyDescriptionFormat.ShortTime);
                //if (duration.Value != null)
                //    vd.MaxiProgress = (int)(duration.Value / Math.Pow(10, 7));
            }
            catch (Exception ex)
            {
            }

            //MediaInfo.MediaInfoWrapper mediaInfoWrapper = new MediaInfo.MediaInfoWrapper(vd.FullName);
            //string result = null;
            //if (mediaInfoWrapper.HasVideo)
            //{
            //    //Dispatcher.Invoke(new Action(() => {
            //    // mediaInfoWrapper.Open(vd.FullName);
            //    //result = mediaInfoWrapper.Get(MediaInfo.StreamKind.General, 0, 167);
            //    result = (mediaInfoWrapper.Tags as AudioTags).Title;
            //    vd.MaxiProgress = mediaInfoWrapper.Duration;
            //    vd.Duration = mediaInfoWrapper.BestVideoStream.Duration.ToString();
            //}
            //mediaInfoWrapper.Close();
            //}),DispatcherPriority.Background);

            return(shell.Properties.System.Title.Value);
        }
コード例 #5
0
        private void NewPlaylist_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            ((IShell.FileView.TreeViewer as ITreeViewer).MoviesPLaylist as PlaylistTree)
            .CreateNewPlayList(vfc.Directory.FullName);
        }
コード例 #6
0
        private void RemovefromPlayList_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                FilePlayerManager.PlaylistManagerViewModel.Remove(vfc);
            }
        }
コード例 #7
0
        private void Play_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                MediaControllerVM.Current.GetVideoItem(vfc, true);
            }
        }
コード例 #8
0
        private void WMPPlay_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                IPlayFile.WMPPlayFileInit(vfc);
            }
        }
コード例 #9
0
        private void RemoveFromLS_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc    = (VideoFolderChild)e.Parameter;
            IFolder          folder = vfc.ParentDirectory;

            vfc.Progress = 0;
            ApplicationService.SavedLastSeenCollection.Remove((PlayedFiles)vfc.LastPlayedPoisition);
            vfc.LastPlayedPoisition = new PlayedFiles(vfc.FileName);
        }
コード例 #10
0
        private void Play_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                FilePlayerManager.MediaControllerViewModel.GetVideoItem(vfc, true);
            }
        }
コード例 #11
0
 private void Previous()
 {
     SavePlayed();
     if (playListManager.CanPrevious)
     {
         CurrentVideoItem          = playListManager.GetPreviousItem();
         axWindowsMediaPlayer1.URL = (CurrentVideoItem.Directory.FullName);
     }
 }
コード例 #12
0
        private void RemoveFromLS_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc    = (VideoFolderChild)e.Parameter;
            IFolder          folder = vfc.ParentDirectory;

            vfc.Progress = 0;
            LastSeenHelper.RemoveLastSeen(folder, vfc.LastPlayedPoisition);
            vfc.LastPlayedPoisition = new PlayedFiles(vfc.FileName);
        }
コード例 #13
0
 private void Next()
 {
     SavePlayed();
     if (playListManager.CanNext)
     {
         CurrentVideoItem          = playListManager.GetNextItem();
         axWindowsMediaPlayer1.URL = (CurrentVideoItem.Directory.FullName);
     }
 }
コード例 #14
0
        private void AddtoPlayList_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                IPlayFile.AddFiletoPlayList(vfc);
            }
        }
コード例 #15
0
        private void RemovefromPlayList_executed(object sender, ExecutedRoutedEventArgs e)
        {
            VideoFolderChild vfc = (VideoFolderChild)e.Parameter;

            if (vfc != null)
            {
                MediaControllerVM.Current.Playlist.Remove(vfc);
            }
        }
コード例 #16
0
        private void RunShellFunction(VideoFolderChild vd)
        {
            string prop = null;

            prop = GetMediaTitle(vd);
            if (!string.IsNullOrEmpty(prop) && !prop.Contains("\""))
            {
                vd.MediaTitle = prop;
            }
        }
コード例 #17
0
        public void AddFiletoPlayList(object obj)
        {
            InitPlayerView();
            MediaControlExtension.SetFileexpVisiblity(VideoElement.PlayListView as UIElement,
                                                      Visibility.Visible);

            VideoFolderChild vfc = (VideoFolderChild)obj;

            MediaControllerVM.Current.Playlist.Add(vfc);
        }
コード例 #18
0
        public void GetVideoItem(VideoFolderChild obj, bool frompl = false)
        {
            if (!MediaPlayerService.HasStopped)
            {
                MediaPlayerService.Stop();
            }

            FilePlayerManager.VideoElement.ContentDockRegion.Content = null;
            NewVideoAction(obj, frompl);
        }
コード例 #19
0
        private VideoFolderChild GetItem_for_Repeat()
        {
            VideoFolderChild item = null;

            IsfetchingRepeatItemAsync = true;
            (IVideoElement as Window).Dispatcher.Invoke(new Action(() =>
            {
                item = this.AsynSearchForNextItem();
            }));

            return(item);
        }
コード例 #20
0
        public VideoFolderChild CreateVideoFolderChild(IFolder Parentdir, FileInfo fileInfo)
        {
            VideoFolderChild vfc = new VideoFolderChild(Parentdir, fileInfo)
            {
                FileSize = filecommonhelper.FileSizeConverter(fileInfo.Length),
                FileType = FileType.File
            };

            vfc.OnFileNameChangedChanged += ParentDir_OnFileNameChangedChanged;
            SetLastSeen(vfc);
            return(vfc);
        }
コード例 #21
0
        private void GetThumbnail(VideoFolderChild file)
        {
            ImageSource imageSource = null;

            dispatcherService.InvokeDispatchAction(new Action(delegate
            {
                file.IsLoading    = true;
                ShellObject shell = ShellObject.FromParsingName(file.FullName);
                file.Thumbnail    = imageSource = shell.Thumbnail.LargeBitmapSource;
                shell.Dispose();
                file.IsLoading = false;
            }));
        }
コード例 #22
0
        public void SetLastSeen(VideoFolderChild videoFolderChild)
        {
            PlayedFiles pdf = applicationService.SavedLastSeenCollection.GetLastSeen(videoFolderChild.FileInfo.Name) as PlayedFiles;

            if (pdf != null)
            {
                videoFolderChild.LastPlayedPoisition = pdf;
            }
            else
            {
                videoFolderChild.LastPlayedPoisition = new PlayedFiles(videoFolderChild.FileInfo.Name);
            }
        }
コード例 #23
0
        internal void OpenFile(VideoFolderChild obj)
        {
            if (CurrentVideoItem == null)
            {
                CurrentVideoItem = obj;
            }
            else if (CurrentVideoItem == obj)
            {
                return;
            }

            axWindowsMediaPlayer1.URL = obj.Directory.FullName;
            if (obj.HasLastSeen)
            {
                resumeposition = obj.LastPlayedPoisition.ProgressLastSeen;
            }
            axWindowsMediaPlayer1.Ctlcontrols.play();
        }
コード例 #24
0
        //public void PlayIndexChanged(ref VideoFolderChild obj)
        //{
        //    this.NowPlaying = obj;
        //}

        public void UpdateNowPlaying(object obj, bool frompl)
        {
            if (NowPlaying == null && !frompl || !this.PlayList.Contains(obj))
            {
                if (CurrentPlaylist != null && HasChanges)
                {
                    SavePlaylistAction();
                }
                CurrentPlaylist = null;
                this.NowPlaying = (VideoFolderChild)obj;
                VideoFolder parent = (VideoFolder)NowPlaying.ParentDirectory;
                PlayList = new ObservableCollection <VideoFolder>();
                _playlist.AddRange(parent.OtherFiles.Where(x => x.FileType == FileType.File).ToList());
            }
            else
            {
                this.NowPlaying = (VideoFolderChild)obj;
            }
        }
コード例 #25
0
        public ObservableCollection <VideoFolder> LoadChildrenFiles(VideoFolder Parentdir, IList <FileInfo> files,
                                                                    bool newpath = false)
        {
            ObservableCollection <VideoFolder> Toparent = new ObservableCollection <VideoFolder>();

            for (int i = 0; i < files.Count; i++)
            {
                if (files[i] == null)
                {
                    continue;
                }
                VideoFolderChild vd = CreateVideoFolderChild(Parentdir, files[i]);
                if (vd != null)
                {
                    Toparent.Add(vd);
                }
            }
            return(Toparent);
        }
コード例 #26
0
        private void NewVideoAction(VideoFolderChild obj, bool frompl = false)
        {
            if (obj == null)
            {
                return;
            }
            if (CurrentVideoItem != null)
            {
                if (obj.FileName == CurrentVideoItem.FileName)
                {
                    return;
                }

                if (!obj.ParentDirectory.Directory.FullName.Equals(CurrentVideoItem.
                                                                   ParentDirectory.Directory.FullName))
                {
                    IsDirectoryChanged = true;
                }
            }

            MediaState = MediaState.Stopped;
            if (obj.SubPath.Count > 0)
            {
                IVideoPlayer.Subtitle.LoadSub(obj.SubPath.First());
            }
            else
            {
                IVideoPlayer.Subtitle.Clear();
                //CSubtitle.ClearSubstitute(); OutlineTextSub.Visibility =
                //System.Windows.Visibility.Collapsed;
            }

            this.currentvideoitem = obj;
            CurrentVideoItemChangedEvent(currentvideoitem, frompl);

            IVideoElement.MediaPlayer.Source = new Uri(obj.FilePath);
            PlayAction();



            RaiseCanPrevNext();
        }
コード例 #27
0
        private void NewVideoAction(VideoFolderChild obj, bool frompl = false)
        {
            (IVideoElement as Window).Dispatcher.BeginInvoke(new Action(() =>
            {
                if (obj == null)
                {
                    return;
                }
                if (CurrentVideoItem != null)
                {
                    if (this.RepeatMode == RepeatMode.RepeatOnce)
                    {
                        if (this.IsPlaying)
                        {
                            this.MediaPlayerService.CurrentTimer
                                = TimeSpan.FromMilliseconds(0);
                            return;
                        }
                        PlayAction();
                        return;
                    }
                    if (obj.FileName == CurrentVideoItem.FileName)
                    {
                        return;
                    }

                    if (!obj.ParentDirectory.Directory.FullName.Equals(CurrentVideoItem.
                                                                       ParentDirectory.Directory.FullName))
                    {
                        IsDirectoryChanged = true;
                    }
                }
                MediaPlayerStop();

                this.currentvideoitem = obj;
                CurrentVideoItemChangedEvent(currentvideoitem, frompl);
                IVideoElement.Title = (obj.FileName);
                MediaPlayerService.LoadMedia(obj.FilePath, MediaPlayerService.VlcOption);
                PlayAction(true);
                CommandManager.InvalidateRequerySuggested();
            }), DispatcherPriority.ContextIdle, null);
        }
コード例 #28
0
        public ObservableCollection <VideoFolder> LoadChildrenFiles(VideoFolder Parentdir, bool newpath = false)
        {
            ObservableCollection <VideoFolder> Toparent = new ObservableCollection <VideoFolder>();
            List <Task>     Tasks = new List <Task>();
            List <FileInfo> files =
                filecommonhelper.GetFilesByExtensions(Parentdir.Directory, applicationService.Formats);

            for (int i = 0; i < files.Count; i++)
            {
                if (files[i] == null)
                {
                    continue;
                }
                VideoFolderChild vd = CreateVideoFolderChild(Parentdir, files[i]);
                if (vd != null)
                {
                    Toparent.Add(vd);
                }
            }
            return(Toparent);
        }
コード例 #29
0
        public static VideoFolder LoadChildrenFiles(DirectoryInfo directoryInfo, bool newpath = false)
        {
            IFolder Parentdir = new VideoFolder(directoryInfo.Parent.FullName);

            ApplicationService.CreateLastSeenFolder(Parentdir);
            ApplicationService.LoadLastSeenFile(Parentdir);
            FileInfo         fileInfo = new FileInfo(directoryInfo.FullName);
            VideoFolderChild vd;
            PlayedFiles      pdf = (PlayedFiles)LastSeenHelper.GetProgress(Parentdir, fileInfo.Name);

            vd = new VideoFolderChild(Parentdir, fileInfo)
            {
                FileSize = FileExplorerCommonHelper.FileSizeConverter(fileInfo.Length),
                FileType = FileType.File
            };
            if (pdf != null)
            {
                vd.LastPlayedPoisition = pdf;
            }
            else
            {
                vd.LastPlayedPoisition = new PlayedFiles(fileInfo.Name);
            }
            IEnumerable <FileInfo> files = null;

            using (ShellObject shell = ShellObject.FromParsingName(vd.FilePath))
            {
                IShellProperty prop = shell.Properties.System.Media.Duration;
                vd.Duration = prop.FormatForDisplay(PropertyDescriptionFormat.ShortTime);
                var duration = shell.Properties.System.Media.Duration;
                if (duration.Value != null)
                {
                    vd.MaxiProgress = double.Parse(duration.Value.ToString());
                }

                files = FileExplorerCommonHelper.GetSubtitleFiles(directoryInfo.Parent);
            }
            vd.SubPath = FileExplorerCommonHelper.MatchSubToMedia(vd.Name, files);
            return(vd);
        }
コード例 #30
0
        public VideoFolder LoadChildrenFiles(DirectoryInfo directoryInfo, bool newpath = false)
        {
            VideoFolder vf = null;

            MovieDataSource.DataSource.TryGetValue(directoryInfo.FullName, out vf);
            if (vf == null)
            {
                VideoFolder      Parentdir = new VideoFolder(directoryInfo.Parent.FullName);
                FileInfo         fileInfo  = new FileInfo(directoryInfo.FullName);
                VideoFolderChild vfc       = CreateVideoFolderChild(Parentdir, fileInfo);
                #region Search For Subtitle
                //IEnumerable<FileInfo> files = null;
                //files = filecommonhelper.GetSubtitleFiles(directoryInfo.Parent);
                //vfc.SubPath = filecommonhelper.MatchSubToMedia(vfc.Name, files);

                //RunShellFunction(vfc);
                #endregion
                return(vfc);
            }

            return(vf);
        }