예제 #1
0
 void mediaElement1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
 {
     if (e.newState == (int)WMPLib.WMPPlayState.wmppsPlaying)
     {
         if (resumeposition != 0)
         {
             axWindowsMediaPlayer1.Ctlcontrols.currentPosition = resumeposition;
             resumeposition = 0;
         }
         if (playstate != 1)
         {
             MediaOpen();
         }
         MediaPositionTimer.Start();
         this.Text = CommonHelper.SetPlayerTitle("Playing", CurrentVideoItem.Directory.FullName);
     }
     else if (e.newState == (int)WMPLib.WMPPlayState.wmppsStopped)
     {
         //Played.RLastPostion(Helper.FileName(URL.uri));
         CurrentVideoItem.LastPlayedPoisition.ProgressLastSeen = (double)CurrentVideoItem.Progress;
         if (!CurrentVideoItem.HasLastSeen && CurrentVideoItem.Progress > 0)
         {
             LastSeenHelper.AddLastSeen(CurrentVideoItem.ParentDirectory, CurrentVideoItem.LastPlayedPoisition);
         }
         MediaPositionTimer.Stop();
         resumeposition = CurrentVideoItem.Progress;
         this.Text      = CommonHelper.SetPlayerTitle("Stopped", CurrentVideoItem.Directory.FullName);
     }
     else if (e.newState == (int)WMPLib.WMPPlayState.wmppsPaused)
     {
         MediaPositionTimer.Stop();
         this.Text = CommonHelper.SetPlayerTitle("Paused", CurrentVideoItem.Directory.FullName);
     }
 }
        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
        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);
        }
예제 #4
0
 private void SavePlayed()
 {
     CurrentVideoItem.LastPlayedPoisition.ProgressLastSeen = (double)axWindowsMediaPlayer1.Ctlcontrols.currentPosition;
     if (!CurrentVideoItem.HasLastSeen && CurrentVideoItem.Progress > 0)
     {
         LastSeenHelper.AddLastSeen(CurrentVideoItem.ParentDirectory, CurrentVideoItem.LastPlayedPoisition);
     }
     ApplicationService.SaveLastSeenFile(CurrentVideoItem.ParentDirectory);
 }
예제 #5
0
 public CollectionViewModel()
 {
     // _aggregator = ServiceLocator.Current.GetInstance<IEventAggregator>();
     // _aggregator.GetEvent<LoadViewExecuteCommandEvent>().Subscribe(LoadViewUpdate);
     // _aggregator.GetEvent<LoadExecuteCommandEvent>().Subscribe(OnVideoItemSelected);
     LastSeen = new LastSeenHelper();
     InitCombox();
     //IsLoaded = false;
     PlayMovie      = new RelayCommand(PlayMovieAction);
     TemplateToggle = new RelayCommand(() => TemplateToggleAction());
     Next           = new DelegateCommand(() => Next_Action(), CanNextExecute);
     Previous       = new DelegateCommand(() => Previous_Action(), CanPreviousExecute);
     Refresh        = new DelegateCommand(() => Refresh_Action(), CanRefresh);
     UpdateView(this.ViewType);
     //  VideoItemPanel
     //  var sds = Application.Current;
 }
        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);
        }
        private void MediaPlayerStop()
        {
            if (CurrentVideoItem == null)
            {
                return;
            }
            CurrentVideoItem.LastPlayedPoisition.ProgressLastSeen = (double)CurrentVideoItem.Progress;
            if (!CurrentVideoItem.HasLastSeen && CurrentVideoItem.Progress > 0)
            {
                LastSeenHelper.AddLastSeen(CurrentVideoItem.ParentDirectory, CurrentVideoItem.LastPlayedPoisition);
            }

            if (mediaState == MediaState.Stopped)
            {
                IVideoElement.MediaPlayer.Stop();
                PlayBackAction(MediaState.ToString());
            }
            CurrentVideoItem.IsActive = false;
            if (IsDirectoryChanged)
            {
                IsDirectoryChanged = false;
                ApplicationService.SaveLastSeenFile(CurrentVideoItem.ParentDirectory);
            }
        }