private void NAudioEngine_PropertyChanged(object sender, PropertyChangedEventArgs e) { NAudioEngine engine = NAudioEngine.Instance; switch (e.PropertyName) { case "FileTag": if (engine.FileTag != null) { TagLib.Tag tag = engine.FileTag.Tag; if (tag.Title != null) { this.Title = "MusicPlayer | " + tag.Album; } if (tag.Title == null) { this.Title = "Music Player"; } if (tag.Pictures.Length > 0) { using (MemoryStream albumArtworkMemStream = new MemoryStream(tag.Pictures[0].Data.Data)) { try { BitmapImage albumImage = new BitmapImage(); albumImage.BeginInit(); albumImage.CacheOption = BitmapCacheOption.OnLoad; albumImage.StreamSource = albumArtworkMemStream; albumImage.EndInit(); albumArtPanel.AlbumArtImage = albumImage; } catch (NotSupportedException) { albumArtPanel.AlbumArtImage = null; // System.NotSupportedException: // No imaging component suitable to complete this operation was found. } albumArtworkMemStream.Close(); } } else { albumArtPanel.AlbumArtImage = null; } } else { albumArtPanel.AlbumArtImage = null; } break; case "ChannelPosition": digitalClock.Time = TimeSpan.FromSeconds(engine.ChannelPosition); break; default: // Do Nothing break; } }
private void NAudioEngine_PropertyChanged(object sender, PropertyChangedEventArgs e) { NAudioEngine instance = NAudioEngine.Instance; string propertyName = e.PropertyName; if (propertyName != null) { clockDisplay.Time = TimeSpan.FromSeconds(instance.ChannelPosition); } }
public MainWindow() { InitializeComponent(); NAudioEngine soundEngine = NAudioEngine.Instance; soundEngine.PropertyChanged += NAudioEngine_PropertyChanged; UIHelper.Bind(soundEngine, "CanStop", Stop, Button.IsEnabledProperty); UIHelper.Bind(soundEngine, "CanPlay", Play, Button.IsEnabledProperty); UIHelper.Bind(soundEngine, "CanPause", Pause, Button.IsEnabledProperty); spectrumAnalyzer.RegisterSoundPlayer(soundEngine); waveformTimeline.RegisterSoundPlayer(soundEngine); }
public AudioPlayer() { InitializeComponent(); NAudioEngine soundEngine = NAudioEngine.Instance; UIHelper.Bind(soundEngine, "CanStop", StopButton, IsEnabledProperty); UIHelper.Bind(soundEngine, "CanPlay", PlayButton, IsEnabledProperty); UIHelper.Bind(soundEngine, "CanPause", PauseButton, IsEnabledProperty); soundEngine.PropertyChanged += NAudioEngine_PropertyChanged; waveformTimeline.RegisterSoundPlayer(soundEngine); Application.Current.Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted; }
public PlayerViewModel() { Songs = new ObservableCollection <Song>(); LoadMusicLibraryAsync(); Player = NAudioEngine.Instance; PlayNextCommand = new RelayCommand(PlayNext); PlayPreviousCommand = new RelayCommand(PlayPrevious); PlayCommand = new RelayCommand(Play); ShowPlaybackQueueCommand = new RelayCommand(ShowPlaybackQueue); VolumePopupOpenCommand = new RelayCommand(OpenVolumePopup); MuteCommand = new RelayCommand(Mute); Player.PropertyChanged += NAudioEngine_PropertyChanged; }
public AudioToolView() : base(DataWindowMode.Custom) { InitializeComponent(); GivenRedAudioSource.Add("Red"); GivenRedAudioSource.Add("Blue"); GivenRedAudioSource.Add("Green"); GivenRedAudioSource.Add("Orange"); GivenRedAudioSource.Add("Purple"); GivenRedAudioSource.Add("White"); GivenRedAudioSource.Add("Black"); PlayListView.ItemsSource = GivenRedAudioSource; ResourceDictionary themeResources = Application.LoadComponent(new Uri("Resources/Styles/ExpressionDark.xaml", UriKind.Relative)) as ResourceDictionary; Resources.MergedDictionaries.Add(themeResources); //clockDisplay.SetCurrentValue(WPFSoundVisualizationLib.DigitalClock.TimeProperty, TimeSpan.FromMilliseconds(channel.CurrentSound.GetLength(TimeUnit.MS))); // this.DataContext = new AudioToolViewModel(); NAudioEngine soundEngine = NAudioEngine.Instance; soundEngine.PropertyChanged += NAudioEngine_PropertyChanged; // UIHelper.Bind(soundEngine, "CanStop", StopButton, Button.IsEnabledProperty); // UIHelper.Bind(soundEngine, "CanPlay", PlayButton, Button.IsEnabledProperty); // UIHelper.Bind(soundEngine, "CanPause", PauseButton, Button.IsEnabledProperty); spectrumAnalyzer.RegisterSoundPlayer(soundEngine); waveformTimeline.RegisterSoundPlayer(soundEngine); //LoadExpressionDarkTheme(); ShowPage(); }
public void NAudioEngineCleanUp() { player = null; }
public void NAudioEngineSetup() { player = NAudioEngine.Instance; player.OpenFile(@"C:\You Raise Me Up.mp3"); }