Beispiel #1
0
 public void ScanDir(MediaLibrary library, string path)
 {
     var files = System.IO.Directory.EnumerateFiles(path, "*.*", System.IO.SearchOption.AllDirectories);
       foreach (string file in files)
       {
     ProcessFile(library, file);
       }
 }
Beispiel #2
0
        public void ProcessFile(MediaLibrary library, string filename)
        {
            File song_metadata;
              try
              {
            song_metadata = File.Create(filename);
              }
              catch (UnsupportedFormatException e)
              {
            return;
              }
              catch (CorruptFileException e)
              {
            return;
              }
              if (song_metadata == null || song_metadata.Tag == null)
              {
            Debug.WriteLine("Missing metadata/tag: " + filename);
            return;
              }
              var tag = song_metadata.Tag;
              if (!tag.AlbumArtists.Any())
              {
            Debug.WriteLine("Missing artist: " + filename);
            return;
              }
              if (string.IsNullOrWhiteSpace(tag.Title))
              {
            Debug.WriteLine("Missing title: " + filename);
            return;
              }

              library.AddSong(new Song
              {
            Title = tag.Title,
            TrackNumber = tag.Track,
            Path = filename
              }, tag.AlbumArtists.First(), tag.Album);
        }
 public EmbeddedServer(MediaLibrary library, uint port)
 {
     EmbeddedServer.library = library;
       string baseAddress = "http://+:" + port + "/";
       app = WebApp.Start<Startup>(url: baseAddress);
 }
    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;
    }