Пример #1
0
    public async void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
      var a = await BackgroundFetcher.RetrieveImage();
      this.mainGrid.Background = new ImageBrush(a);

      mediaLibrary = new MediaLibrary();
      embeddedServer = new EmbeddedServer(mediaLibrary, 49931);

      //TagReader tr = new TagReader();
     // tr.ScanDir(mediaLibrary, @"D:\Music\");

      var musicMenu = new ListMenu("music", artistsMenu);

      var artists = mediaLibrary.Artists().ToList();
      artists.ForEach(x =>
      {
        var s = new MenuEntry(x.Name);
        s.Item = x;
        musicMenu.Items.Add(s);
      });
      pushMenu(musicMenu);

      myVlcControl.TimeChanged += (Vlc.DotNet.Wpf.VlcControl vlccontrol, VlcEventArgs<TimeSpan> eventargs) =>
      {
        currentTime.Text = FormatTimespan(eventargs.Data);
        //totalTime.Text = FormatTimespan(vlccontrol.Media.Duration);
      };
  
      myVlcControl.PositionChanged += (Vlc.DotNet.Wpf.VlcControl vlccontrol, VlcEventArgs<float> eventargs) =>
      {
        progress.Value = 100 * eventargs.Data;
        totalTime.Text = "" + GC.GetTotalMemory(false) / 1000000 + " MB";
      };

      myVlcControl.Paused += (Vlc.DotNet.Wpf.VlcControl vlccontrol, VlcEventArgs<EventArgs> eventargs) =>
      {
        if (barTimer != null)
        {
          barTimer.Stop();
        }
        showNowPlayingBar();
      };

      myVlcControl.Stopped += (Vlc.DotNet.Wpf.VlcControl vlccontrol, VlcEventArgs<EventArgs> eventargs) =>
      {
          videoPanel.Visibility = Visibility.Collapsed;
      };
      myVlcControl.Playing += (Vlc.DotNet.Wpf.VlcControl vlccontrol, VlcEventArgs<EventArgs> eventargs) =>
      {
       // songName.Text =  vlccontrol.Media.Metadatas.Title;
        //artistName.Text = "" + vlccontrol.Media.Metadatas.Artist;
        if (vlccontrol.VideoProperties.Size.IsEmpty)
        {
          videoPanel.Visibility = Visibility.Collapsed;
        }
        else
        {
          videoPanel.Visibility = Visibility.Visible;
          barTimer = new System.Timers.Timer();
          barTimer.Elapsed += (object source, ElapsedEventArgs ee) =>
          {
            this.Dispatcher.Invoke((Action)(() =>
            {
              hideNowPlayingBar();
            }));
          };
          barTimer.AutoReset = false;
          barTimer.Interval = 3000;
          barTimer.Enabled = true;
        }
      };    
      Mouse.OverrideCursor = Cursors.None;     
      VlcContext.LibVlcDllsPath = CommonStrings.LIBVLC_DLLS_PATH_DEFAULT_VALUE_AMD64;
      VlcContext.LibVlcPluginsPath = CommonStrings.PLUGINS_PATH_DEFAULT_VALUE_AMD64;
      VlcContext.StartupOptions.ScreenSaverEnabled = false;
      VlcContext.StartupOptions.IgnoreConfig = true;
      VlcContext.StartupOptions.LogOptions.LogInFile = true;
      VlcContext.StartupOptions.LogOptions.ShowLoggerConsole = true;
      VlcContext.StartupOptions.LogOptions.Verbosity = VlcLogVerbosities.Debug;
    }
Пример #2
0
 private void popMenu()
 {
   if (menuStack.Count > 0)
   {
     curMenu.List.Visibility = Visibility.Collapsed;
     curMenu.List.ItemsSource = null;
     curMenu = menuStack.Pop();
     curMenu.List.Visibility = Visibility.Visible;
     curMenu.List.Focus();
     menuTitle.Text = curMenu.Title;
   }
 }
Пример #3
0
 private void pushMenu(ListMenu newMenu)
 {
   if (curMenu != null)
   {
     curMenu.List.Visibility = Visibility.Collapsed;
     menuStack.Push(curMenu);
   }
   curMenu = newMenu;
   curMenu.selectedItem(0);
   curMenu.List.Visibility = Visibility.Visible;
   curMenu.List.Focus();
   menuTitle.Text = curMenu.Title;
 }
Пример #4
0
    protected override void OnKeyDown(KeyEventArgs e)
    {
      if (e.Key == Key.Q)
      {
        VlcContext.CloseAll();

        Application.Current.Shutdown();
      }
      if (e.Key == Key.Escape)
      {
        popMenu();
      }

      if (e.Key == Key.Enter)
      {
        if (curMenu.List.SelectedItem == null)
        {
          return;
        }
        MenuEntry item = (MenuEntry)curMenu.List.SelectedItem;
        if (item.Item is Song)
        {
          Song a = (item.Item as Song);
          if (myVlcControl.Medias.Any())
          {
            myVlcControl.Medias.RemoveAt(0);
            myVlcControl.Stop();
          }
          var file = new PathMedia(a.Path);
          myVlcControl.Play(file);

          showNowPlayingBar();
          artistName.Text = a.Artist.Name;
          songName.Text = a.Title;
        }
        if (item.Item is Artist)
        {
          Artist a = (item.Item as Artist);
          var albumMenu = new ListMenu(a.Name, albumsMenu);
          var albums = a.Albums.ToList(); 
          albums.ForEach(x =>
          {
            var s = new MenuEntry(x.Name);
            s.Item = x;
            albumMenu.Items.Add(s);
          });    
          pushMenu(albumMenu);
        }
        if (item.Item is Album)
        {
          Album a = (item.Item as Album);
          var songMenu = new ListMenu(a.Name, songsMenu);
          var songs = a.Songs.ToList();
          songs.ForEach(x =>
          {
            var s = new MenuEntry(x.Title);
            s.Item = x;
            songMenu.Items.Add(s);
          });           
          pushMenu(songMenu);
        }
      }
      base.OnKeyDown(e);
    }