コード例 #1
0
 /// <summary>
 /// Fires the OpeningMediaItemPart event
 /// </summary>
 /// <param name="part">Part that is opening</param>
 private void OnOpeningMediaItemPart(MediaItemPart part)
 {
     if (OpeningMediaItemPart != null)
     {
         OpeningMediaItemPart(this, new MediaItemPartEventArgs(part));
     }
 }
コード例 #2
0
 /// <summary>
 /// Fires the PartExtracted event
 /// </summary>
 /// <param name="part">Part that was extracted</param>
 private void OnPartExtracted(MediaItemPart part)
 {
     if (PartExtracted != null)
     {
         PartExtracted(this, new MediaItemPartEventArgs(part));
     }
 }
コード例 #3
0
        /// <summary>
        /// Switches two items in the collection
        /// </summary>
        /// <param name="index1">Index of the first item being switched</param>
        /// <param name="index2">Index of the second item being switched</param>
        private void SwitchParts(Int16 index1, Int16 index2)
        {
            try
            {
                if (IsOrganising)
                {
                    GeneralMethods.MessageBoxApplicationError("Please wait for the library to finish organising before editing any media items");
                    return;
                }

                List <MediaItemPart> parts = new List <MediaItemPart>(MediaItem.Parts);

                MediaItemPart part1 = parts[index1];
                MediaItemPart part2 = parts[index2];

                if (part1 != part2)
                {
                    part1.Index = index2;
                    part2.Index = index1;

                    parts[index1] = part2;
                    parts[index2] = part1;

                    parts.Sort();

                    MediaItem.Parts = new MediaItemPartCollection(parts);
                }
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not switch parts: ");
            }
        }
コード例 #4
0
        /// <summary>
        /// Extracts the part to a new media item
        /// </summary>
        /// <param name="part">Part being extracted</param>
        private void ExtractPart(MediaItemPart part)
        {
            try
            {
                if (IsOrganising)
                {
                    GeneralMethods.MessageBoxApplicationError("Please wait for the library to finish organising before extracting the parts of any media items");
                    return;
                }

                CancelMediaItemsOperationEventArgs e = new CancelMediaItemsOperationEventArgs(new MediaItem[1] {
                    SelectedMediaItem
                });
                OnExtractingPartFromMediaItem(e);

                if (e.Cancel)
                {
                    GeneralMethods.MessageBoxApplicationError(e.ReasonForCancel);
                    return;
                }

                MediaItem extractedFrom = dgMediaItems.SelectedItem as MediaItem;
                MediaItem extractedTo;

                switch (extractedFrom.Type)
                {
                case MediaItemTypeEnum.Song:
                    extractedTo = new Song();
                    break;

                case MediaItemTypeEnum.Video:
                    extractedTo = new Video();
                    break;

                default:
                    throw new UnknownEnumValueException(extractedFrom.Type);
                }

                extractedTo.Parts.Add(part.Location, part.Size, part.Duration);

                MediaItemDialog mediaItemDialog = new MediaItemDialog(true, extractedTo);
                mediaItemDialog.Owner          = Application.Current.MainWindow;
                mediaItemDialog.ShowHidden     = Filter.ShowHidden;
                mediaItemDialog.FileTypeAdded += new FileTypeEventHandler(mediaItemDialog_FileTypeAdded);

                if (GeneralMethods.GetNullableBoolValue(mediaItemDialog.ShowDialog()))
                {
                    extractedFrom.Parts.Remove(part.Location);
                    OnMediaItemSaved(extractedFrom);

                    OnMediaItemSaved(extractedTo);
                }
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not extract part: ");
            }
        }
コード例 #5
0
 /// <summary>
 /// Initialises a new instance of the OrganisingMediaItemPart class
 /// </summary>
 /// <param name="mediaItem">Media item the part being organised belongs to</param>
 /// <param name="partIndex">Index in the media item's collection of the part being organised</param>
 /// <param name="organisedPath">Path the part will be moved to</param>
 /// <param name="requiresMove">Value determining whether the part needs to be moved</param>
 public OrganisingMediaItemPart(MediaItem mediaItem, int partIndex, IntelligentString organisedPath, Boolean requiresMove)
 {
     this.mediaItem     = mediaItem;
     this.part          = mediaItem.Parts[partIndex];
     this.organisedPath = organisedPath;
     this.progress      = 0;
     this.status        = OrganisingMediaItemPartStatus.Waiting;
     this.errors        = new Dictionary <IntelligentString, Exception>();
     this.timeTaken     = TimeSpan.FromSeconds(0);
     this.requiresMove  = requiresMove;
 }
コード例 #6
0
        private static void OnSelectedMediaItemPartIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MediaItemPlayer mip = d as MediaItemPlayer;

            if (mip.SelectedMediaItem != null)
            {
                MediaItemPart selectedMediaItemPart = mip.SelectedMediaItem.Parts[mip.SelectedMediaItemPartIndex];
                mip.SelectedMediaItemPart = selectedMediaItemPart;
            }
            else
            {
                mip.SelectedMediaItemPart = null;
            }
        }
コード例 #7
0
 /// <summary>
 /// Initialises a new instance of the MediaItemExists class
 /// </summary>
 /// <param name="mediaItem">Media item the part that doesn't exist belongs to</param>
 /// <param name="partIndex">Index in the media item's collection of the part that doesn't exist</param>
 public MediaItemExists(MediaItem mediaItem, Int32 partIndex)
 {
     this.mediaItem = mediaItem;
     this.part      = mediaItem.Parts[partIndex];
 }
コード例 #8
0
        /// <summary>
        /// Browses for a media file to add to the media item parts collection
        /// </summary>
        public void BrowseForMediaFiles()
        {
            try
            {
                if (IsOrganising)
                {
                    GeneralMethods.MessageBoxApplicationError("Please wait for the library to finish organising before editing any media items");
                    return;
                }

                FileType[] fileTypes = App.GetFileTypesForMediaItem(MediaItem);

                if (fileTypes != null)
                {
                    String[] filenames = BrowseForMediaFilenames(fileTypes, true);

                    if (filenames.Length > 0)
                    {
                        Dictionary <MediaItemPart, TimeSpan> parts = new Dictionary <MediaItemPart, TimeSpan>();

                        foreach (String filename in filenames)
                        {
                            if (MediaItem.MediaItemPartLocationExists(filename))
                            {
                                GeneralMethods.MessageBoxApplicationError("There is already a " + MediaItem.Type.ToString().ToLower() + " in the system with the filename: \"" + filename + "\"");
                                return;
                            }

                            FileInfo fi = new FileInfo(filename);

                            if (!fileTypes.Any(p => p.Extensions.Any(e => e.Value.ToLower() == fi.Extension.ToLower())))
                            {
                                try
                                {
                                    FileType fileType = GetFileTypeForExtension(fileTypes, fi.Extension, MediaItem.Type);

                                    if (fileType != null)
                                    {
                                        fileType.Save();

                                        if (!fileTypes.Contains(fileType))
                                        {
                                            OnFileTypeAdded(fileType);
                                        }
                                    }
                                }
                                catch (System.Exception e)
                                {
                                    GeneralMethods.MessageBoxException(e, "Could not add extension to file type: ");
                                }
                            }

                            MediaItemPart part = new MediaItemPart(fi.FullName)
                            {
                                Size = fi.Length, Index = Convert.ToInt16(MediaItem.Parts.Count)
                            };

                            //store the duration of the part
                            parts.Add(part, MediaItem.GetDuration(fi.FullName));
                        }

                        foreach (KeyValuePair <MediaItemPart, TimeSpan> part in parts)
                        {
                            MediaItemPart newPart = MediaItem.Parts.Add(part.Key.Location, part.Key.Size, part.Key.Duration);
                            MediaItem.SetPartDuration(newPart.Index, part.Value);
                        }

                        OnPartAdded(parts.Keys.ToArray());
                    }
                }
            }
            catch (System.Exception e)
            {
                GeneralMethods.MessageBoxException(e, "Could not add part: ");
            }
        }
コード例 #9
0
ファイル: MediaServicesService.cs プロジェクト: rgardler/dpp
        public void RemoveMediaItem(MediaItemPart mediaItemPart)
        {
            var toDelete = _videoMediaItemRepository.Table.Where(vm => vm.MediaItemRecord != null && vm.MediaItemRecord.Id == mediaItemPart.Id);
            foreach (var videoMediaItemRecord in toDelete) {
                _videoMediaItemRepository.Delete(videoMediaItemRecord);
            }
            var mediaItem = mediaItemPart.Record;
            if (mediaItem != null) {
                DeleteByAssetId(mediaItem.AssetId);

                var encodedItems = _encodedMediaRepository.Table.Where(em => em.MediaItem.Id == mediaItem.Id);
                foreach (var encodedMediaRecord in encodedItems) {
                    DeleteByAssetId(encodedMediaRecord.AssetId);
                    _encodedMediaRepository.Delete(encodedMediaRecord);
                    if (encodedMediaRecord.EncodingPreset.MediaType != MediaType.Image) {
                        continue;
                    }
                    var record = encodedMediaRecord;
                    var thumbnails = _thumbnailRepository.Table.Where(t => t.EncodedMedia.Id == record.Id);
                    foreach (var thumbnailRecord in thumbnails) {
                        _thumbnailRepository.Delete(thumbnailRecord);
                    }
                }

                _orchardServices.ContentManager.Remove(mediaItemPart.ContentItem);
            }
        }
コード例 #10
0
 /// <summary>
 /// Initialises a new instance of the MediaItemPartEventArgs class
 /// </summary>
 /// <param name="part">Part</param>
 public MediaItemPartEventArgs(MediaItemPart part)
 {
     this.part = part;
 }