Esempio n. 1
0
        // Help UI to get notified using dispatcher asyncronously
        private void Tracks_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
            {
                //if (task == null || task.Status != TaskStatus.Running)
                //{
                TrackVM[] tracks = (e.NewItems.Cast <TrackVM>()).ToArray();

                task = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < tracks.Length; i++)
                    {
                        TrackVM item = tracks[i];
                        TracklistProvider.Instance.UpdateTrackTagInfo(item);
                    }
                });
                //}
            }

            foreach (PluginVM item in Plugins)
            {
                if (item.IsEnabled)
                {
                    item.Plugin.TracklistUpdated(TracklistProvider.Instance.Tracks.Select(o => o.Location).ToArray());
                }
            }
        }
Esempio n. 2
0
        void UpdateInfo()
        {
            if (task == null || task.Status != TaskStatus.Running)
            {
                var container = TinyIoC.TinyIoCContainer.Current;

                IMessageProvider messageProvider = container.Resolve <IMessageProvider>(Naming.ContainerNSR.MESSAGE_PROVIDER);

                task = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < SelectedTracks.Count(); i++)
                    {
                        TrackVM item = SelectedTracks.ElementAt(i);
                        TracklistProvider.Instance.UpdateTrackTagInfo(item);
                    }
                }).ContinueWith(o =>
                {
                    RootDispatcher.Dispatcher.Invoke(() =>
                    {
                        string message = messageProvider.TrackInfoUpdated;

                        if (MessageUpdated != null)
                        {
                            MessageUpdated(this, new MessageEventArgs {
                                Message = message
                            });
                        }
                    });
                });
            }
        }
Esempio n. 3
0
        private void Instance_TrackTagInfoUpdated(TrackVM trackVM, Un4seen.Bass.AddOn.Tags.TAG_INFO tagInfo)
        {
            RootDispatcher.Dispatcher.Invoke(new System.Action(() =>
            {
                System.Diagnostics.Debug.WriteLine("Instance_TrackTagInfoUpdated: " + tagInfo.title);

                ObservableCollection <TrackVM> tracks = TracklistProvider.Instance.Tracks;

                int index = tracks.IndexOf(trackVM);
                if (index >= 0)
                {
                    tracks[index].Title  = tagInfo.title;
                    tracks[index].Artist = tagInfo.artist;
                    tracks[index].Album  = tagInfo.album;
                    tracks[index].Length = Un4seen.Bass.Utils.FixTimespan(tagInfo.duration, "MMSS");
                }
            }));
        }
Esempio n. 4
0
        private void Timer_Tick(object sender, System.EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("Starting track update...");

            if (task == null || task.Status != TaskStatus.Running)
            {
                TrackVM[] tracks = TracklistProvider.Instance.Tracks.Where(x => x.Location.StartsWith(("http"))).ToArray();

                task = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    for (int i = 0; i < tracks.Length; i++)
                    {
                        TrackVM item = tracks[i];
                        TracklistProvider.Instance.UpdateTrackTagInfo(item);
                    }
                });
            }
        }
Esempio n. 5
0
        private void Instance_MetaUpdated(Un4seen.Bass.AddOn.Tags.TAG_INFO tagInfo)
        {
            RootDispatcher.Dispatcher.Invoke(new System.Action(() =>
            {
                System.Diagnostics.Debug.WriteLine("Track meta updated");

                TrackVM track = TracklistProvider.Instance.GetCurrentTrack();

                track.Title  = tagInfo.title;
                track.Album  = tagInfo.album;
                track.Artist = tagInfo.artist;
                track.Length = Un4seen.Bass.Utils.FixTimespan(tagInfo.duration, "MMSS");
            }));

            foreach (PluginVM item in Plugins)
            {
                if (item.IsEnabled)
                {
                    item.Plugin.RetrieveInfo(TracklistProvider.Instance.GetCurrentTrack().Location, AudioControllerService.Current.ChannelInfo, tagInfo);
                }
            }
        }