Click here to Skip to main content
13,294,516 members (58,280 online)
Click here to Skip to main content
Add your own
alternative version


21 bookmarked
Posted 20 Oct 2005

AviScreensaver: A C# screensaver that allows you to play your favourites media files

, 20 Oct 2005
Rate this:
Please Sign up or sign in to vote.
The screensaver plays from 1 to 16 video (or media files) simultaneously.

Sample Image - AviScreenSaver.jpg


A screensaver consists of a form that can load from 1 to 16 Windows MediaPlayer controls. Each MediaPlayer control loads media files selected by the user, stores them in a random playlist, and then plays all the media Files. It can play all Windows Media Player supported formats (video files, image files, music).

private void ScreenSaverForm_Load(object sender, System.EventArgs e)
   TopMost = true;
   // uso playlist perchè in futuro potrò selezionare più files
   string playlistName;
   string playlistBase = "ABU Video ScreenSaver Playlist";
   string[] selectedfiles = null;
   if (this.ScreenSettings.FileToPlay != String.Empty)
      selectedfiles = this.ScreenSettings.FileToPlay.Split(',');
   string[] folderFiles = 
   int len = 0;
   if (selectedfiles != null)
      len += selectedfiles.Length;
   if (folderFiles!=null)
      len += folderFiles.Length;
   string[] files = new string[len];
   int startIndex = 0;
   if (selectedfiles != null)
      selectedfiles.CopyTo(files, startIndex);
      startIndex = selectedfiles.Length;
   // aggiungo i files della cartella
   if (folderFiles!=null)
      folderFiles.CopyTo(files, startIndex);
   // randomizzo
   string[] filesShuffled;
   // nota bene:
   // anche se posso gestire più riquadri video
   // in questo momento ne uso sempre e SOLO 1
   // perchè media player si arrabbia con più video in simultanea
   int cnt = 0;
   foreach (UserControl c in this.panelVideo.Controls)
      playlistName = playlistBase + cnt.ToString();
      if (this.ScreenSettings.Shuffle)
         filesShuffled = Shuffle(files);
         filesShuffled = files;
      VideoFrame vfr = (VideoFrame)c;
      Microsoft.MediaPlayer.Interop.IWMPPlaylist pl;
      pl = vfr.axWindowsMediaPlayer.mediaCollection.getByName(playlistName);
      if (pl != null)
         pl = vfr.axWindowsMediaPlayer.playlistCollection.newPlaylist(
      for(int i=0; i<=filesShuffled.Length-1; i++)
         if (System.IO.File.Exists(filesShuffled[i]))
            Microsoft.MediaPlayer.Interop.IWMPMedia m = 
      vfr.axWindowsMediaPlayer.currentPlaylist = pl;
   // lancio i play tutti insieme
   foreach (UserControl c in this.panelVideo.Controls)
      VideoFrame vfr = (VideoFrame)c;;


Windows Media Player 9 or greater.

Updates / Fixes

  • 21/10/2005: Changed form options language to English; fixed setup project that wasn't deploying a DLL.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Marco Roello
Web Developer
Italy Italy
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralReferences Missing Pin
wjones23087720-Oct-05 4:14
memberwjones23087720-Oct-05 4:14 
GeneralRe: References Missing Pin
Marco Roello20-Oct-05 6:40
memberMarco Roello20-Oct-05 6:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171207.1 | Last Updated 20 Oct 2005
Article Copyright 2005 by Marco Roello
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid