Exemple #1
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var chatId = (long)parameter;

            if (state.TryGet("selectedIndex", out int selectedIndex))
            {
                SelectedIndex = selectedIndex;
            }

            //Peer = (TLInputPeerBase)parameter;
            //With = Peer is TLInputPeerUser ? (ITLDialogWith)CacheService.GetUser(Peer.ToPeer().Id) : CacheService.GetChat(Peer.ToPeer().Id);

            Chat = ProtoService.GetChat(chatId);

            Media = new MediaCollection(ProtoService, chatId, new SearchMessagesFilterPhotoAndVideo());
            Files = new MediaCollection(ProtoService, chatId, new SearchMessagesFilterDocument());
            Links = new MediaCollection(ProtoService, chatId, new SearchMessagesFilterUrl());
            Music = new MediaCollection(ProtoService, chatId, new SearchMessagesFilterAudio());
            Voice = new MediaCollection(ProtoService, chatId, new SearchMessagesFilterVoiceNote());

            RaisePropertyChanged(() => Media);
            RaisePropertyChanged(() => Files);
            RaisePropertyChanged(() => Links);
            RaisePropertyChanged(() => Music);
            RaisePropertyChanged(() => Voice);

            Aggregator.Subscribe(this);
            return(Task.CompletedTask);
        }
 public SequenceTypeDataModelBase()
 {
     Media          = new MediaCollection();
     LocalDataSet   = new ModuleLocalDataSet();
     SequenceLayers = new SequenceLayers();
     _InitDataStreams();
 }
        public VirtualFolders(String path)
        {
            _folders = new MediaCollection { };
            _dir = new DirectoryInfo(path);

            StreamReader sr;
            String img, fold;
            Folder fo;
            foreach (FileInfo f in _dir.GetFiles("*.vf"))
            {
                sr = new StreamReader(f.FullName);
                img = sr.ReadLine();
                fold = sr.ReadLine();
                sr.Close();

                img = img.Substring(7);
                fold = fold.Substring(8);

                fo = new Folder(fold, this);
                fo.folderImage = img;
                try
                {
                    fo.fetchContents();
                }
                catch
                {
                    continue;
                }
                _folders.Add(fo);
            }
        }
Exemple #4
0
        public Season(DirectoryInfo d, Series seriesparent)
            : base(d)
        {
            if (backdropImage == "/Images/nobackdrop.jpg")
                backdropImage = seriesparent.backdropImage;
            if (folderImage == "/Images/nofolder.jpg")
                folderImage = seriesparent.folderImage;

            title = d.Name;
            _series = seriesparent;

            Episodes = new MediaCollection { };

            Regex videos = new Regex(".*\\.(avi|mkv|mp4|mpg|mpeg|ogm|wmv|divx|dvr-ms)$");

            foreach (FileInfo f in d.GetFiles())
            {
                if (videos.IsMatch(f.Name))
                {
                    Episode ep = new Episode(f, this);
                    if (ep.Valid)
                        Episodes.Add(ep);
                }
            }

            LoadImage(backdropImage);
            LoadImage(folderImage);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,BorrowRequests,ApplicationUserId")] MediaCollection mediaCollection)
        {
            if (id != mediaCollection.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mediaCollection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MediaCollectionExists(mediaCollection.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(mediaCollection));
        }
        void SurrogateRead(StreamingContext context)
        {
            SelectedTimingProvider = _selectedTimingProviderSurrogate.CreateSelectedTimingProvider();
            Media = new MediaCollection(_mediaSurrogates.Select(x => x.CreateMedia()));

            // Rehydrate the local module data store.
            LocalDataSet            = new ModuleLocalDataSet();
            LocalDataSet.DataModels = _dataModels;

            // Rehydrate the modules.
            IEffectNode[]         effectNodes         = _effectNodeSurrogates.Select(x => x.CreateEffectNode()).ToArray();
            ISequenceFilterNode[] sequenceFilterNodes = _filterNodeSurrogates.Select(x => x.CreateFilterNode()).ToArray();

            // Connect them to their respective data from the data store.
            // This was previously being done by adding the data to the sequence after loading the data.
            foreach (var effectNode in effectNodes)
            {
                LocalDataSet.AssignModuleInstanceData(effectNode.Effect);
            }
            foreach (var sequenceFilterNode in sequenceFilterNodes)
            {
                LocalDataSet.AssignModuleInstanceData(sequenceFilterNode.Filter);
            }

            // Get the modules back into their collections.
            _InitDataStreams();
            EffectData.AddData(effectNodes);
            SequenceFilterData.AddData(sequenceFilterNodes);
        }
        private bool CallPlayMediaUsingMediaCollection(MediaCenterEnvironment mediaCenterEnvironment, PlayableItem playable)
        {
            MediaCollection coll = new MediaCollection();

            // Create a MediaCollectionItem for each file to play
            if (playable.HasMediaItems)
            {
                PlaybackControllerHelper.PopulateMediaCollectionUsingMediaItems(this, coll, playable);
            }
            else
            {
                PlaybackControllerHelper.PopulateMediaCollectionUsingFiles(coll, playable);
            }

            // Set starting position if we're resuming
            if (playable.Resume)
            {
                var playstate = playable.MediaItems.First().PlaybackStatus;

                coll.CurrentIndex = playstate.PlaylistPosition;
                coll[playstate.PlaylistPosition].Start = new TimeSpan(playstate.PositionTicks);
            }

            _CurrentMediaCollection = coll;

            bool success = PlaybackControllerHelper.CallPlayMedia(mediaCenterEnvironment, MediaType.MediaCollection, _CurrentMediaCollection, false);

            if (!success)
            {
                _CurrentMediaCollection = null;
            }

            return(success);
        }
Exemple #8
0
        public void Find(SearchMessagesFilter filter, string query)
        {
            switch (filter)
            {
            case SearchMessagesFilterPhotoAndVideo photoAndVideo:
                Media = new MediaCollection(ProtoService, Chat.Id, photoAndVideo, query);
                RaisePropertyChanged(() => Media);
                break;

            case SearchMessagesFilterDocument document:
                Files = new MediaCollection(ProtoService, Chat.Id, document, query);
                RaisePropertyChanged(() => Files);
                break;

            case SearchMessagesFilterUrl url:
                Links = new MediaCollection(ProtoService, Chat.Id, url, query);
                RaisePropertyChanged(() => Links);
                break;

            case SearchMessagesFilterAudio audio:
                Music = new MediaCollection(ProtoService, Chat.Id, audio, query);
                RaisePropertyChanged(() => Music);
                break;

            case SearchMessagesFilterVoiceNote voiceNote:
                Voice = new MediaCollection(ProtoService, Chat.Id, voiceNote, query);
                RaisePropertyChanged(() => Voice);
                break;
            }
        }
        /// <summary>
        /// Handles a change of Playstate by firing various events and post play processes
        /// </summary>
        private void HandleStoppedState(MediaCenterEnvironment env, MediaExperience exp, MediaTransport transport, PlaybackStateEventArgs e)
        {
            // Stop listening to the events
            env.PropertyChanged       -= MediaCenterEnvironment_PropertyChanged;
            transport.PropertyChanged -= MediaTransport_PropertyChanged;

            // This will prevent us from getting in here twice after playback stops and calling post-play processes more than once.
            _HasStartedPlaying = false;

            _CurrentMediaCollection = null;

            var mediaType = exp.MediaType;

            // Check if internal wmc player is still playing, which could happen if the user launches live tv while playing something
            if (mediaType != Microsoft.MediaCenter.Extensibility.MediaType.TV)
            {
                Application.CurrentInstance.ShowNowPlaying = false;

                if (mediaType == Microsoft.MediaCenter.Extensibility.MediaType.Audio || mediaType == Microsoft.MediaCenter.Extensibility.MediaType.DVD)
                {
                    PlaybackControllerHelper.ReturnToApplication(true);
                }
            }

            // Fire the OnFinished event for each item
            OnPlaybackFinished(e);
        }
Exemple #10
0
 public void AddNewContentList(IList <MediaList> newlist)
 {
     foreach (var item in newlist)
     {
         MediaCollection.Add(item);
     }
     MediaCollection.OrderBy(x => x.Number);
 }
        //SHOW ITEM
        public ActionResult ShowItem(int CollectionId)
        {
            MediaCollection MediaCollection = new MediaCollection();

            MediaCollection         = repository.GetMediaCollectionDescription(CollectionId);
            ViewBag.collectionTitle = MediaCollection.ShortTitle.ToString();

            return(View(repository.TransformToVideoMediaCollection(CollectionId)));
        }
        protected override void ResetPlaybackProperties()
        {
            base.ResetPlaybackProperties();

            _CurrentMediaCollection  = null;
            _HasStartedPlaying       = false;
            _CurrentPlayState        = Microsoft.MediaCenter.PlayState.Undefined;
            _LastTransportUpdateTime = DateTime.Now;
        }
        protected override void ResetPlaybackProperties()
        {
            base.ResetPlaybackProperties();

            _CurrentMediaCollection = null;
            _HasStartedPlaying = false;
            _CurrentPlayState = Microsoft.MediaCenter.PlayState.Undefined;
            _LastTransportUpdateTime = DateTime.Now;
        }
Exemple #14
0
        //SHOW ITEM
        public ActionResult ShowItem(int CollectionId)
        {
            MediaCollection MediaCollection = new MediaCollection();

            MediaCollection          = repository.GetMediaCollectionDescription(CollectionId);
            ViewBag.collectionTitle  = MediaCollection.ShortTitle.ToString();
            ViewBag.collectionFolder = MediaCollection.Location.ToString();

            return(View(MediaCollection.MediaElements.ToList()));
        }
        private void SurrogateRead(StreamingContext context)
        {
            SelectedTimingProvider = _selectedTimingProviderSurrogate.CreateSelectedTimingProvider();
            Media = new MediaCollection(_mediaSurrogates.Select(x => x.CreateMedia()));

            // Rehydrate the local module data store.
            LocalDataSet            = new ModuleLocalDataSet();
            LocalDataSet.DataModels = _dataModels;

            // Rehydrate the modules.
            var elementNodes = VixenSystem.Nodes.Distinct().ToDictionary(x => x.Id);

            IEffectNode[] effectNodes = _effectNodeSurrogates.Select(x => x.CreateEffectNode(elementNodes)).ToArray();
            // weed out effects without nodes..
            effectNodes = effectNodes.Where(x => x.Effect.TargetNodes.Count() != 0).ToArray();

            ISequenceFilterNode[] sequenceFilterNodes = _filterNodeSurrogates.Select(x => x.CreateFilterNode()).ToArray();

            // Connect them to their respective data from the data store.
            // This was previously being done by adding the data to the sequence after loading the data.
            foreach (var effectNode in effectNodes)
            {
                LocalDataSet.AssignModuleInstanceData(effectNode.Effect);
            }
            foreach (var sequenceFilterNode in sequenceFilterNodes)
            {
                LocalDataSet.AssignModuleInstanceData(sequenceFilterNode.Filter);
            }

            if (SequenceLayers != null)
            {
                var layerMixingFilterModels = new ModuleLocalDataSet {
                    DataModels = _layerMixingFilterDataModels
                };
                //Bring in the layers
                foreach (var layer in SequenceLayers.Layers)
                {
                    var surrogate = _layerMixingFilterSurrogates.FirstOrDefault(x => x.LayerReferenceId == layer.Id);
                    if (surrogate != null)
                    {
                        layer.LayerMixingFilter = surrogate.CreateLayerMixingFilter();
                        layerMixingFilterModels.AssignModuleInstanceData(layer.LayerMixingFilter);
                    }
                }
            }
            else
            {
                SequenceLayers = new SequenceLayers();
            }

            // Get the modules back into their collections.
            _InitDataStreams();
            EffectData.AddData(effectNodes);
            SequenceFilterData.AddData(sequenceFilterNodes);
        }
        public async Task <IActionResult> Create([Bind("Id,BorrowRequests,ApplicationUserId")] MediaCollection mediaCollection)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mediaCollection);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(mediaCollection));
        }
Exemple #17
0
        public ActionResult ShowCollection(int CollectionId)
        {
            MediaCollection MediaCollection = new MediaCollection();

            MediaCollection          = repository.GetMediaCollectionDescription(CollectionId);
            ViewBag.User             = this.User.Identity.Name.ToString();
            ViewBag.CollectionTitle  = MediaCollection.Title.ToString();
            ViewBag.Description      = MediaCollection.Description.ToString();
            ViewBag.CollectionFolder = MediaCollection.Location.ToString();
            return(View(MediaCollection));
        }
Exemple #18
0
 protected Sequence()
 {
     FilePath = "";
     InsertDataListener = new InsertDataListenerStack();
     InsertDataListener += _DataListener;
     Data = new DataStreams();
     _sequenceFilterStreamId = Data.CreateStream("SequenceFilter");
     TimingProvider = new TimingProviders(this);
     RuntimeBehaviors = Modules.ModuleManagement.GetAllRuntimeBehavior();
     ModuleDataSet = new ModuleLocalDataSet();
     _media = new MediaCollection();
 }
        public void It_should_build_a_collection_from_subfolders()
        {
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
            {
                { @"C:\Media\A", new MockDirectoryData() },
                { @"C:\Media\B", new MockDirectoryData() },
                { @"C:\Media\C", new MockDirectoryData() }
            });
            IMediaCollection<IFilmFromFolder> m = new MediaCollection<FilmFromFolder>(@"C:\Media", fileSystem);

            CollectionAssert.AreEqual(new[] { "A", "B", "C" }, m.Items.Select(f => f.FolderName).ToArray());
        }
Exemple #20
0
        public void SelectMedia(IMediaObject media)
        {
            int index = MediaCollection.IndexOf((IMediaObject)media);

            _mediaServer.ServeSpecific(index);
            SendPropertyChanged(nameof(CurrentMedia));
            _mediaTimer.Initialize(CurrentMedia.Duration, () => MediaHasEnded());
            if (Play)
            {
                _mediaTimer.Start();
            }
        }
Exemple #21
0
        public void It_should_build_a_collection_from_subfolders()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"C:\Media\A", new MockDirectoryData() },
                { @"C:\Media\B", new MockDirectoryData() },
                { @"C:\Media\C", new MockDirectoryData() }
            });
            IMediaCollection <IFilmFromFolder> m = new MediaCollection <FilmFromFolder>(@"C:\Media", fileSystem);

            CollectionAssert.AreEqual(new[] { "A", "B", "C" }, m.Items.Select(f => f.FolderName).ToArray());
        }
 /// <summary>
 /// Calls PlayMedia using either a MediaCollection or a single file
 /// </summary>
 private bool CallPlayMediaForPlayableItem(MediaCenterEnvironment mediaCenterEnvironment, PlayableItem playable)
 {
     if (PlaybackControllerHelper.UseLegacyApi(playable))
     {
         bool success = CallPlayMediaLegacy(mediaCenterEnvironment, playable);
         _CurrentMediaCollection = null;
         return(success);
     }
     else
     {
         return(CallPlayMediaUsingMediaCollection(mediaCenterEnvironment, playable));
     }
 }
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            Media = new MediaCollection(ProtoService, (TLInputPeerBase)parameter, new TLInputMessagesFilterPhotoVideo());
            Files = new MediaCollection(ProtoService, (TLInputPeerBase)parameter, new TLInputMessagesFilterDocument());
            Links = new MediaCollection(ProtoService, (TLInputPeerBase)parameter, new TLInputMessagesFilterUrl());
            Music = new MediaCollection(ProtoService, (TLInputPeerBase)parameter, new TLInputMessagesFilterMusic());

            RaisePropertyChanged(() => Media);
            RaisePropertyChanged(() => Files);
            RaisePropertyChanged(() => Links);
            RaisePropertyChanged(() => Music);

            return(Task.CompletedTask);
        }
Exemple #24
0
        public Folder(String fol, VirtualFolders vf)
            : base(new DirectoryInfo(fol))
        {
            _dir = DirInfo;
            _contents = new MediaCollection { };
            _vfs = vf;

            transX = 200;
            transY = 100;

            backdropImage = "/Images/backdrop.jpg";

            title = _dir.Name;
        }
Exemple #25
0
        public static void Run(string[] args)
        {
            var options = new Options();
            var parser  = new CommandLine.Parser(s =>
            {
                s.CaseSensitive     = false;
                s.MutuallyExclusive = true;
                s.HelpWriter        = Console.Out;
                s.ParsingCulture    = System.Globalization.CultureInfo.InvariantCulture;
            });

            if (!parser.ParseArguments(args, options))
            {
                return;
            }

            if (options.Folders.Count > 0)
            {
                var firstFolder = options.Folders.First();
                var collection  = new MediaCollection <ConsoleFilm>(firstFolder).Items;

                if (options.List)
                {
                    foreach (var film in collection)
                    {
                        Console.WriteLine(String.Format("{0,-3} {1,-9} {2}", film.Rating, film.ImdbId, film.FolderName));
                    }
                }

                if (options.Decorate)
                {
                    new IconService().ProcessValidFilms(collection, validFilms =>
                                                        Console.WriteLine("Complete! " + validFilms.Count() + " folders have been decorated with icons."));
                }

                if (options.Watch)
                {
                    new ConsoleFilmProcessingWatcher(firstFolder).InfiniteWait();
                }
            }

            if (options.RunGui)
            {
                GuiApp.Run();
            }
        }
Exemple #26
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            Peer = (TLInputPeerBase)parameter;
            With = Peer is TLInputPeerUser ? (ITLDialogWith)CacheService.GetUser(Peer.ToPeer().Id) : CacheService.GetChat(Peer.ToPeer().Id);

            Media = new MediaCollection(ProtoService, _peer, new TLInputMessagesFilterPhotoVideo());
            Files = new MediaCollection(ProtoService, _peer, new TLInputMessagesFilterDocument());
            Links = new MediaCollection(ProtoService, _peer, new TLInputMessagesFilterUrl());
            Music = new MediaCollection(ProtoService, _peer, new TLInputMessagesFilterMusic());

            RaisePropertyChanged(() => Media);
            RaisePropertyChanged(() => Files);
            RaisePropertyChanged(() => Links);
            RaisePropertyChanged(() => Music);

            return(Task.CompletedTask);
        }
Exemple #27
0
        public Series(DirectoryInfo di, Folder f)
            : base(di)
        {
            SeriesXml = new XPathDocument(DirInfo.GetFiles("series.xml").First().OpenText());
            SeriesNav = SeriesXml.CreateNavigator();

            Seasons = new MediaCollection { };

            _folder = f;

            title = this.ToString();

            foreach (DirectoryInfo d in DirInfo.GetDirectories())
            {
                Seasons.Add(new Season(d, this));
            }
        }
Exemple #28
0
        public static void Run(string[] args)
        {
            var options = new Options();
            var parser = new CommandLine.Parser(s =>
            {
                s.CaseSensitive = false;
                s.MutuallyExclusive = true;
                s.HelpWriter = Console.Out;
                s.ParsingCulture = System.Globalization.CultureInfo.InvariantCulture;
            });
            if (!parser.ParseArguments(args, options))
            {
                return;
            }

            if (options.Folders.Count > 0)
            {
                var firstFolder = options.Folders.First();
                var collection = new MediaCollection<ConsoleFilm>(firstFolder).Items;

                if (options.List)
                {
                    foreach (var film in collection)
                    {
                        Console.WriteLine(String.Format("{0,-3} {1,-9} {2}", film.Rating, film.ImdbId, film.FolderName));
                    }
                }

                if(options.Decorate)
                {
                    new IconService().ProcessValidFilms(collection, validFilms =>
                        Console.WriteLine("Complete! " + validFilms.Count() + " folders have been decorated with icons."));
                }

                if(options.Watch)
                {
                    new ConsoleFilmProcessingWatcher(firstFolder).InfiniteWait();
                }
            }

            if (options.RunGui)
            {
                GuiApp.Run();
            }
        }
Exemple #29
0
 public MediaViewModel(
     Media media,
     MediaCollection mediaCollection,
     string albumName, byte[] key,
     ReadOnlyObservableCollection <string> allTags,
     ReadOnlyObservableCollection <string> allCharacterTags,
     ReadOnlyObservableCollection <string> allCharacterNames)
 {
     _mediaCollection   = mediaCollection;
     _albumName         = albumName;
     _key               = key;
     _stream            = null;
     _observer          = null;
     _done              = false;
     _allTags           = allTags;
     _allCharacterTags  = allCharacterTags;
     _allCharacterNames = allCharacterNames;
     Media              = media;
 }
Exemple #30
0
        public void AddFolder()
        {
            var dialog = new CommonOpenFileDialog {
                IsFolderPicker = true
            };

            if (dialog.ShowDialog(Application.Current.MainWindow) == CommonFileDialogResult.Ok)
            {
                openFolder = dialog.FileName;
                if (System.IO.Directory.Exists(openFolder))
                {
                    Collection = new MediaCollection <GuiFilm>(openFolder).Items;
                }
                else
                {
                    MessageBox.Show("The directory " + openFolder + " does not exist.", "No Such Folder", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        /// <summary>
        /// Then playback is based on Media items, this will populate the MediaCollection using the items
        /// </summary>
        public static void PopulateMediaCollectionUsingMediaItems(PlaybackController controllerInstance, MediaCollection coll, PlayableItem playable)
        {
            int currentFileIndex = 0;
            int collectionIndex = coll.Count;
            int numItems = playable.MediaItems.Count();

            for (int mediaIndex = 0; mediaIndex < numItems; mediaIndex++)
            {
                Media media = playable.MediaItems.ElementAt(mediaIndex);

                IEnumerable<string> files = controllerInstance.GetPlayableFiles(media);

                int numFiles = files.Count();

                // Create a MediaCollectionItem for each file to play
                for (int i = 0; i < numFiles; i++)
                {
                    string path = files.ElementAt(i);

                    Dictionary<string, object> friendlyData = new Dictionary<string, object>();

                    // Embed the playlist index, since we could have multiple playlists queued up
                    // which prevents us from being able to use MediaCollection.CurrentIndex
                    friendlyData["FilePlaylistPosition"] = currentFileIndex.ToString();

                    // Embed the PlayableItemId so we can identify which one to track progress for
                    friendlyData["PlayableItemId"] = playable.Id.ToString();

                    // Embed the Media index so we can identify which one to track progress for
                    friendlyData["MediaIndex"] = mediaIndex.ToString();

                    // Set a friendly title
                    friendlyData["Title"] = media.Name;

                    coll.AddItem(path, collectionIndex, -1, string.Empty, friendlyData);

                    currentFileIndex++;
                    collectionIndex++;
                }
            }
        }
Exemple #32
0
        public ActionResult AddCollection_Attributes(MediaCollection MediaCollection)
        {
            ViewBag.User = this.User.Identity.Name.ToString();

            if (ModelState.IsValid)
            {
/*                try
 *              {
 *                  mgallery.Save();
 *              }
 *              catch (RuleException ex)
 *              {
 *                  ex.CopyToModelState(ModelState);
 *              }
 */

                MediaCollection.UserName = User.Identity.Name;
                repository.AddMediaCollectionDescription(MediaCollection);
            }

            return(ModelState.IsValid ? View("AddCollection_File") : View());
        }
Exemple #33
0
        /// <summary>
        /// When playback is based purely on file paths, this will populate the MediaCollection using the paths
        /// </summary>
        public static void PopulateMediaCollectionUsingFiles(MediaCollection coll, PlayableItem playable, int startIndex, int count)
        {
            int    numFiles = playable.Files.Count();
            string idString = playable.Id.ToString();

            // Create a MediaCollectionItem for each file to play
            for (int i = startIndex; i < count; i++)
            {
                string path = playable.Files.ElementAt(i);

                Dictionary <string, object> friendlyData = new Dictionary <string, object>();

                // Embed the playlist index, since we could have multiple playlists queued up
                // which prevents us from being able to use MediaCollection.CurrentIndex
                friendlyData["FilePlaylistPosition"] = i.ToString();

                // Embed the PlayableItemId so we can identify which one to track progress for
                friendlyData["PlayableItemId"] = idString;

                coll.AddItem(path, i, -1, string.Empty, friendlyData);
            }
        }
Exemple #34
0
            public SelectedMedia(SelectForm selectForm)
            {
                m_Parent = selectForm;

                m_ItemsStringFormat          = new StringFormat(StringFormatFlags.NoWrap);
                m_ItemsStringFormat.Trimming = StringTrimming.EllipsisCharacter;
                m_Items = new MediaCollection(this);

                m_Parent.pbSelectedMediaItems.Paint += new PaintEventHandler(pbChoosedView_Paint);

                m_Parent.pbCancelBtn.Tag = Properties.Resources.Page2_33_Press;


                new ScrollWrapper(m_Parent.pbSelectedMediaTopScroll,
                                  m_Parent.pbSelectedMediaBottomScroll, imgTopScrollPressed,
                                  imgBottomScrollPressed, 1, 60, new ScrollDel(
                                      delegate(Int32 nPos)
                {
                    if (m_Items.Count > m_ItemsInWnd)
                    {
                        if (nPos + m_ItemOffset >= 0 && nPos + m_ItemOffset + m_ItemsInWnd <= m_Items.Count)
                        {
                            m_ItemOffset += nPos;
                            OnItemsStateChanged();
                        }
                    }
                }));

                m_Parent.pbCancelBtn.Click += new EventHandler(pbCancelBtn_Click);
                m_Parent.pbGo.Click        += new EventHandler(pbGo_Click);

                //Init
                m_RestSum            = CBInfo.Instance.SumNow.Value;
                m_Parent.lblSum.Text = m_RestSum.ToString();

                m_Parent.Shown       += new EventHandler(m_Parent_Shown);
                m_Parent.FormClosing += new FormClosingEventHandler(m_Parent_FormClosing);
            }
        /// <summary>
        /// Retrieves the current playback item using MediaCollection properties
        /// </summary>
        public static PlayableItem GetCurrentPlaybackItemFromMediaCollection(IEnumerable<PlayableItem> allPlayableItems, MediaCollection currentMediaCollection, out int filePlaylistPosition, out int currentMediaIndex)
        {
            filePlaylistPosition = -1;
            currentMediaIndex = -1;

            MediaCollectionItem activeItem = currentMediaCollection.Count == 0 ? null : currentMediaCollection[currentMediaCollection.CurrentIndex];

            if (activeItem == null)
            {
                return null;
            }
            
            Guid playableItemId = new Guid(activeItem.FriendlyData["PlayableItemId"].ToString());
            filePlaylistPosition = int.Parse(activeItem.FriendlyData["FilePlaylistPosition"].ToString());

            object objMediaIndex = activeItem.FriendlyData["MediaIndex"];

            if (objMediaIndex != null)
            {
                currentMediaIndex = int.Parse(objMediaIndex.ToString());
            }

            return allPlayableItems.FirstOrDefault(p => p.Id == playableItemId);
        }
        public MediaCollectionTests()
        {
            _mediaService     = Substitute.For <IMediaService>();
            _fileService      = Substitute.For <IFileService>();
            _progressNotifier = Substitute.For <IProgressNotifier>();
            _configuration    = new Configuration(new ConfigurationDto {
                HistoryPathFormats = new [] { @"yy\yy mm dd" }
            }, _fileService);
            _mediaCollection = new MediaCollection(_configuration, () => _progressNotifier,
                                                   _fileService, _mediaService);

            _mediaService.GetMediaFiles(Arg.Any <string>(), Arg.Any <INotifierInstance>())
            .Returns(new[] {
                Path1,
                Path2,
                Path3,
                Path4
            });

            _mediaService.CreateMediaFile(Path1).Returns(MediaFile1);
            _mediaService.CreateMediaFile(Path2).Returns(MediaFile2);
            _mediaService.CreateMediaFile(Path3).Returns(MediaFile3);
            _mediaService.CreateMediaFile(Path4).Returns(MediaFile4);
        }
 private void AddItems(MediaCollection mc, MediaItem selected)
 {
     foreach (MediaItem mi in mc)
     {
         _dataSource.Add(mi);
         if (mi == selected)
         {
             _elementFlow.SelectedIndex = _dataSource.IndexOf(mi);
             currentItem = mi;
         }
     }
 }
        private void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            //videoURL = "Q:\\Anime\\Black Lagoon [EngSub]\\Season 101x01 - The Black Lagoon.mkv";

            // Get reference to ElementFlow
            DependencyObject obj = VisualTreeHelper.GetChild(_itemsControl, 0);
            while ((obj is Controls.ElementFlow) == false)
            {
                obj = VisualTreeHelper.GetChild(obj, 0);
            }

            _elementFlow = obj as Controls.ElementFlow;
            _elementFlow.SelectedIndexChanged += EFSelectedIndexChanged;
            _elementFlow.SelectedIndex = 0;
            _elementFlow.ElementHeight = Folder.elementH;
            _elementFlow.ElementWidth = Folder.elementW;

            // This makes binding work ???
            window.DataContext = this;

            _dataSource = FindResource("TestDataSource") as MediaCollection;

            this.Dispatcher.Invoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(
                    delegate()
                    {
                        InitialLoad();
                    }
                ));
        }
        public bool Play(BaseItem item)
        {
            var coll = new MediaCollection();
            if (item.ThemeVideos != null)
            {
                for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++ )
                {
                    item.ThemeVideos.ForEach(v => coll.AddItem(v.Path));
                }

                IsPlayingVideo = true;
            }

            else if (item.ThemeSongs != null)
            {
                for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++)
                {
                    item.ThemeSongs.ForEach(a => coll.AddItem(a.Path));
                }

                IsPlayingVideo = false;
            }
            else if (Config.Instance.PlayTrailerAsBackground)
            {
                var movie = item as Movie;
                if (movie != null && movie.TrailerFiles.Any())
                {
                    for (var i = 0; i < Config.Instance.ThemeBackgroundRepeat; i++)
                    {
                        foreach (var trailerFile in movie.TrailerFiles)
                        {
                            coll.AddItem(trailerFile);
                        }
                    }

                    IsPlayingVideo = true;
                }
            }

            if (coll.Any())
            {
                //stop anything currently playing
                PlaybackControllerHelper.Stop();

                var mce = AddInHost.Current.MediaCenterEnvironment;
                mce.PropertyChanged += EnvironmentPropertyChange;

                if (mce.PlayMedia(MediaType.MediaCollection, coll, false))
                {
                    IsPlaying = true;
                    Application.CurrentInstance.ShowNowPlaying = IsPlayingVideo;
                    CurrentScope = item;
                    return true;
                }
                else
                {
                    mce.PropertyChanged -= EnvironmentPropertyChange;
                }
            }

            return false;
        }
        /// <summary>
        /// Then playback is based on Media items, this will populate the MediaCollection using the items
        /// </summary>
        public static void PopulateMediaCollectionUsingMediaItems(PlaybackController controllerInstance, MediaCollection coll, PlayableItem playable)
        {
            int currentFileIndex = 0;
            int collectionIndex = coll.Count;
            int numItems = playable.MediaItems.Count();

            for (int mediaIndex = 0; mediaIndex < numItems; mediaIndex++)
            {
                Media media = playable.MediaItems.ElementAt(mediaIndex);

                IEnumerable<string> files = controllerInstance.GetPlayableFiles(media);

                int numFiles = files.Count();

                // Create a MediaCollectionItem for each file to play
                for (int i = 0; i < numFiles; i++)
                {
                    string path = files.ElementAt(i);

                    Dictionary<string, object> friendlyData = new Dictionary<string, object>();

                    // Embed the playlist index, since we could have multiple playlists queued up
                    // which prevents us from being able to use MediaCollection.CurrentIndex
                    friendlyData["FilePlaylistPosition"] = currentFileIndex.ToString();

                    // Embed the PlayableItemId so we can identify which one to track progress for
                    friendlyData["PlayableItemId"] = playable.Id.ToString();

                    // Embed the Media index so we can identify which one to track progress for
                    friendlyData["MediaIndex"] = mediaIndex.ToString();

                    // Set a friendly title
                    friendlyData["Title"] = media.Name;

                    var song = media as Song;

                    if (song != null)
                    {
                        var itemImage = song.PrimaryImagePath;

                        // The following "friendly" data fields are undocumented but working for song items...
                        if (playable.Folder != null)
                        {
                            // This is either a music album or a playlist
                            friendlyData["AlbumTitle"] = playable.Folder.Name;
                            if (string.IsNullOrEmpty(itemImage))
                            {
                                itemImage = playable.Folder.PrimaryImagePath;
                            }
                        }
                        else
                        {
                            friendlyData["AlbumTitle"] = song.Album;
                        }

                        friendlyData["AlbumArtist"] = song.AlbumArtist;
                        friendlyData["Artist"] = song.Artist;
                        friendlyData["TrackNumber"] = currentFileIndex;

                        if (song.PremierDate != DateTime.MinValue)
                        {
                            friendlyData["YearReleased"] = song.PremierDate.Year;
                        }

                        if (!string.IsNullOrEmpty(itemImage))
                        {
                            friendlyData["AlbumCoverUrl"] = itemImage;
                        }
                    }

                    coll.AddItem(path, collectionIndex, -1, string.Empty, friendlyData);
                    
                    currentFileIndex++;
                    collectionIndex++;
                }
            }
        }
        private void SurrogateRead(StreamingContext context)
        {
            SelectedTimingProvider = _selectedTimingProviderSurrogate.CreateSelectedTimingProvider();
            Media = new MediaCollection(_mediaSurrogates.Select(x => x.CreateMedia()));

            // Rehydrate the local module data store.
            LocalDataSet = new ModuleLocalDataSet();
            LocalDataSet.DataModels = _dataModels;

            // Rehydrate the modules.
            var elementNodes = VixenSystem.Nodes.Distinct().ToDictionary(x => x.Id);
            IEffectNode[] effectNodes = _effectNodeSurrogates.Select(x => x.CreateEffectNode(elementNodes)).ToArray();
            // weed out effects without nodes..
            effectNodes = effectNodes.Where(x => x.Effect.TargetNodes.Count() != 0).ToArray();

            ISequenceFilterNode[] sequenceFilterNodes = _filterNodeSurrogates.Select(x => x.CreateFilterNode()).ToArray();

            // Connect them to their respective data from the data store.
            // This was previously being done by adding the data to the sequence after loading the data.
            foreach (var effectNode in effectNodes) {
                LocalDataSet.AssignModuleInstanceData(effectNode.Effect);
            }
            foreach (var sequenceFilterNode in sequenceFilterNodes) {
                LocalDataSet.AssignModuleInstanceData(sequenceFilterNode.Filter);
            }

            // Get the modules back into their collections.
            _InitDataStreams();
            EffectData.AddData(effectNodes);
            SequenceFilterData.AddData(sequenceFilterNodes);
        }
        internal static void SeedMediaCollection(EntertainmentSystemDbContext context)
        {
            if (context.MediaCollections.Any())
            {
                return;
            }

            var collection = new MediaCollection
            {
                Name = "Warcraft"
            };

            context.MediaCollections.Add(collection);
            context.SaveChanges();
        }
Exemple #43
0
        /// <summary>
        /// Retrieves the current playback item using MediaCollection properties
        /// </summary>
        public static PlayableItem GetCurrentPlaybackItemFromMediaCollection(IEnumerable <PlayableItem> allPlayableItems, MediaCollection currentMediaCollection, out int filePlaylistPosition, out int currentMediaIndex)
        {
            filePlaylistPosition = -1;
            currentMediaIndex    = -1;

            MediaCollectionItem activeItem = currentMediaCollection.Count == 0 ? null : currentMediaCollection[currentMediaCollection.CurrentIndex];

            if (activeItem == null)
            {
                return(null);
            }

            Guid playableItemId = new Guid(activeItem.FriendlyData["PlayableItemId"].ToString());

            filePlaylistPosition = int.Parse(activeItem.FriendlyData["FilePlaylistPosition"].ToString());

            object objMediaIndex = activeItem.FriendlyData["MediaIndex"];

            if (objMediaIndex != null)
            {
                currentMediaIndex = int.Parse(objMediaIndex.ToString());
            }

            return(allPlayableItems.FirstOrDefault(p => p.Id == playableItemId));
        }
 public void Update(MediaCollection entity)
 {
     this.collections.Update(entity);
     this.collections.Save();
 }
 public void DeletePermanent(MediaCollection entity)
 {
     this.collections.DeletePermanent(entity);
     this.collections.Save();
 }
Exemple #46
0
 public void AddFolder()
 {
     var dialog = new CommonOpenFileDialog { IsFolderPicker = true };
     if (dialog.ShowDialog(Application.Current.MainWindow) == CommonFileDialogResult.Ok)
     {
         openFolder = dialog.FileName;
         if(System.IO.Directory.Exists(openFolder))
         {
             Collection = new MediaCollection<GuiFilm>(openFolder).Items;
         }
         else
         {
             MessageBox.Show("The directory " + openFolder + " does not exist.", "No Such Folder", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
Exemple #47
0
 public Disk(MediaFactory factory)
 {
     MusicTracks = factory.CreateMusicTracks();
     Images      = factory.CreateImages();
 }
        /// <summary>
        /// When playback is based purely on file paths, this will populate the MediaCollection using the paths
        /// </summary>
        public static void PopulateMediaCollectionUsingFiles(MediaCollection coll, PlayableItem playable, int startIndex, int count)
        {
            int numFiles = playable.Files.Count();
            string idString = playable.Id.ToString();

            // Create a MediaCollectionItem for each file to play
            for (int i = startIndex; i < count; i++)
            {
                string path = playable.Files.ElementAt(i);

                Dictionary<string, object> friendlyData = new Dictionary<string, object>();

                // Embed the playlist index, since we could have multiple playlists queued up
                // which prevents us from being able to use MediaCollection.CurrentIndex
                friendlyData["FilePlaylistPosition"] = i.ToString();

                // Embed the PlayableItemId so we can identify which one to track progress for
                friendlyData["PlayableItemId"] = idString;

                coll.AddItem(path, i, -1, string.Empty, friendlyData);
            }
        }
 /// <summary>
 /// When playback is based purely on file paths, this will populate the MediaCollection using the paths
 /// </summary>
 public static void PopulateMediaCollectionUsingFiles(MediaCollection coll, PlayableItem playable)
 {
     PopulateMediaCollectionUsingFiles(coll, playable, 0, playable.Files.Count());
 }
 /// <summary>
 /// Calls PlayMedia using either a MediaCollection or a single file
 /// </summary>
 private bool CallPlayMediaForPlayableItem(MediaCenterEnvironment mediaCenterEnvironment, PlayableItem playable)
 {
     if (PlaybackControllerHelper.UseLegacyApi(playable))
     {
         bool success = CallPlayMediaLegacy(mediaCenterEnvironment, playable);
         _CurrentMediaCollection = null;
         return success;
     }
     else
     {
         return CallPlayMediaUsingMediaCollection(mediaCenterEnvironment, playable);
     }
 }
Exemple #51
0
        /// <summary>
        /// Then playback is based on Media items, this will populate the MediaCollection using the items
        /// </summary>
        public static void PopulateMediaCollectionUsingMediaItems(PlaybackController controllerInstance, MediaCollection coll, PlayableItem playable)
        {
            int currentFileIndex = 0;
            int collectionIndex  = coll.Count;
            int numItems         = playable.MediaItems.Count();

            for (int mediaIndex = 0; mediaIndex < numItems; mediaIndex++)
            {
                Media media = playable.MediaItems.ElementAt(mediaIndex);

                IEnumerable <string> files = controllerInstance.GetPlayableFiles(media);

                int numFiles = files.Count();

                // Create a MediaCollectionItem for each file to play
                for (int i = 0; i < numFiles; i++)
                {
                    string path = files.ElementAt(i);

                    Dictionary <string, object> friendlyData = new Dictionary <string, object>();

                    // Embed the playlist index, since we could have multiple playlists queued up
                    // which prevents us from being able to use MediaCollection.CurrentIndex
                    friendlyData["FilePlaylistPosition"] = currentFileIndex.ToString();

                    // Embed the PlayableItemId so we can identify which one to track progress for
                    friendlyData["PlayableItemId"] = playable.Id.ToString();

                    // Embed the Media index so we can identify which one to track progress for
                    friendlyData["MediaIndex"] = mediaIndex.ToString();

                    // Set a friendly title
                    friendlyData["Title"] = media.Name;

                    coll.AddItem(path, collectionIndex, -1, string.Empty, friendlyData);

                    currentFileIndex++;
                    collectionIndex++;
                }
            }
        }
        private bool CallPlayMediaUsingMediaCollection(MediaCenterEnvironment mediaCenterEnvironment, PlayableItem playable)
        {
            MediaCollection coll = new MediaCollection();

            // Create a MediaCollectionItem for each file to play
            if (playable.HasMediaItems)
            {
                PlaybackControllerHelper.PopulateMediaCollectionUsingMediaItems(this, coll, playable);
            }
            else
            {
                PlaybackControllerHelper.PopulateMediaCollectionUsingFiles(coll, playable);
            }

            // Set starting position if we're resuming
            if (playable.Resume)
            {
                var playstate = playable.MediaItems.First().PlaybackStatus;

                coll.CurrentIndex = playstate.PlaylistPosition;
                coll[playstate.PlaylistPosition].Start = new TimeSpan(playstate.PositionTicks);
            }

            _CurrentMediaCollection = coll;

            bool success = PlaybackControllerHelper.CallPlayMedia(mediaCenterEnvironment, MediaType.MediaCollection, _CurrentMediaCollection, false);

            if (!success)
            {
                _CurrentMediaCollection = null;
            }

            return success;
        }
Exemple #53
0
 /// <summary>
 /// When playback is based purely on file paths, this will populate the MediaCollection using the paths
 /// </summary>
 public static void PopulateMediaCollectionUsingFiles(MediaCollection coll, PlayableItem playable)
 {
     PopulateMediaCollectionUsingFiles(coll, playable, 0, playable.Files.Count());
 }
        /// <summary>
        /// Handles a change of Playstate by firing various events and post play processes
        /// </summary>
        private void HandleStoppedState(MediaCenterEnvironment env, MediaExperience exp, MediaTransport transport, PlaybackStateEventArgs e)
        {
            Logger.ReportVerbose("In HandleStoppedState");
            // Stop listening to the events
            env.PropertyChanged -= MediaCenterEnvironment_PropertyChanged;
            transport.PropertyChanged -= MediaTransport_PropertyChanged;

            Logger.ReportVerbose("Events unhooked");

            // This will prevent us from getting in here twice after playback stops and calling post-play processes more than once.
            _HasStartedPlaying = false;

            _CurrentMediaCollection = null;

            var mediaType = exp.MediaType;


            // Check if internal wmc player is still playing, which could happen if the user launches live tv while playing something
            if (mediaType != Microsoft.MediaCenter.Extensibility.MediaType.TV)
            {
                Logger.ReportVerbose("Turning off NPV");
                Application.CurrentInstance.ShowNowPlaying = false;

                if (mediaType == Microsoft.MediaCenter.Extensibility.MediaType.Audio || mediaType == Microsoft.MediaCenter.Extensibility.MediaType.DVD)
                {
                    PlaybackControllerHelper.ReturnToApplication(true);
                }
            }
            else
            {
                Logger.ReportVerbose("Not turning off NPV because Live TV is playing.");
            }

            // Fire the OnFinished event for each item
            Async.Queue("Playback Finished", () => OnPlaybackFinished(e));
        }
 public SequenceTypeDataModelBase()
 {
     Media = new MediaCollection();
     LocalDataSet = new ModuleLocalDataSet();
     _InitDataStreams();
 }