Index: src/Extensions/Banshee.PlayQueue/Resources/ActiveSourceUI.xml
===================================================================
--- src/Extensions/Banshee.PlayQueue/Resources/ActiveSourceUI.xml	(revision 4864)
+++ src/Extensions/Banshee.PlayQueue/Resources/ActiveSourceUI.xml	(working copy)
@@ -1,6 +1,7 @@
 <ui>
     <toolbar name="HeaderToolbar">
         <placeholder name="SourceActions">
+        		<toolitem action="RandomTracksAction" />
             <toolitem action="ClearPlayQueueAction" />
         </placeholder>
     </toolbar>
Index: src/Extensions/Banshee.PlayQueue/Resources/GlobalUI.xml
===================================================================
--- src/Extensions/Banshee.PlayQueue/Resources/GlobalUI.xml	(revision 4864)
+++ src/Extensions/Banshee.PlayQueue/Resources/GlobalUI.xml	(working copy)
@@ -2,10 +2,12 @@
     <popup name="PlayQueueContextMenu">
         <menuitem action="ClearPlayQueueAction"></menuitem>
         <menuitem action="ClearPlayQueueOnQuitAction"></menuitem>
+		  <menuitem action="AutoDJAction"></menuitem>
+		  <menuitem action="RandomTracksAction"></menuitem>
     </popup>
     <popup name="TrackContextMenu" action="TrackContextMenuAction">
         <placeholder name="AboveAddToPlaylist">
             <menuitem name="AddToPlayQueue" action="AddToPlayQueueAction"></menuitem>
         </placeholder>
     </popup>
-</ui>
\ No newline at end of file
+</ui>
Index: src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
===================================================================
--- src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj	(revision 4864)
+++ src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj	(working copy)
@@ -1,77 +1,87 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>8.0.50727</ProductVersion>
-    <ProjectGuid>{74B2E4CC-2701-4C8B-A11D-6E4443F4B21B}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <UseParentDirectoryAsNamespace>true</UseParentDirectoryAsNamespace>
-    <AssemblyName>Banshee.PlayQueue</AssemblyName>
-    <SchemaVersion>2.0</SchemaVersion>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>..\..\..\bin</OutputPath>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
-    <CustomCommands>
-      <CustomCommands>
-        <Command type="Build" command="make" workingdir="${SolutionDir}" />
-        <Command type="Execute" command="make run" workingdir="${SolutionDir}" />
-      </CustomCommands>
-    </CustomCommands>
-    <AssemblyKeyFile>.</AssemblyKeyFile>
-  </PropertyGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\Core\Banshee.Core\Banshee.Core.csproj">
-      <Project>{2ADB831A-A050-47D0-B6B9-9C19D60233BB}</Project>
-      <Name>Banshee.Core</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\..\Core\Banshee.Services\Banshee.Services.csproj">
-      <Project>{B28354F0-BA87-44E8-989F-B864A3C7C09F}</Project>
-      <Name>Banshee.Services</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\..\Core\Banshee.ThickClient\Banshee.ThickClient.csproj">
-      <Project>{AC839523-7BDF-4AB6-8115-E17921B96EC6}</Project>
-      <Name>Banshee.ThickClient</Name>
-    </ProjectReference>
-  </ItemGroup>
-  <ItemGroup>
-    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Banshee.PlayQueue\PlayQueueSource.cs" />
-    <Compile Include="Banshee.PlayQueue\PlayQueueActions.cs" />
-    <Compile Include="Banshee.PlayQueue\IPlayQueue.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="Resources\ActiveSourceUI.xml">
-      <LogicalName>ActiveSourceUI.xml</LogicalName>
-    </EmbeddedResource>
-    <EmbeddedResource Include="Resources\GlobalUI.xml">
-      <LogicalName>GlobalUI.xml</LogicalName>
-    </EmbeddedResource>
-    <EmbeddedResource Include="Banshee.PlayQueue.addin.xml" />
-  </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <ProjectExtensions>
-    <MonoDevelop>
-      <Properties>
-        <GtkDesignInfo />
-        <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="./Makefile.am">
-          <BuildFilesVar Sync="true" Name="SOURCES" />
-          <DeployFilesVar />
-          <ResourcesVar Sync="true" Name="RESOURCES" />
-          <OthersVar />
-          <GacRefVar />
-          <AsmRefVar />
-          <ProjectRefVar />
-        </MonoDevelop.Autotools.MakefileInfo>
-      </Properties>
-    </MonoDevelop>
-  </ProjectExtensions>
+﻿<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>8.0.50727</ProductVersion>
+    <ProjectGuid>{74B2E4CC-2701-4C8B-A11D-6E4443F4B21B}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <UseParentDirectoryAsNamespace>true</UseParentDirectoryAsNamespace>
+    <AssemblyName>Banshee.PlayQueue</AssemblyName>
+    <SchemaVersion>2.0</SchemaVersion>
+    <RootNamespace>
+    </RootNamespace>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..\..\..\bin\</OutputPath>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+    <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+    <CustomCommands>
+      <CustomCommands>
+        <Command type="Build" command="make" workingdir="${SolutionDir}" />
+        <Command type="Execute" command="make run" workingdir="${SolutionDir}" />
+      </CustomCommands>
+    </CustomCommands>
+    <AssemblyKeyFile>.</AssemblyKeyFile>
+    <OutputType>Library</OutputType>
+    <AssemblyName>Banshee.PlayQueue</AssemblyName>
+    <RootNamespace>
+    </RootNamespace>
+    <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
+    <DefineConstants>
+    </DefineConstants>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
+    <Reference Include="Banshee.Core, Version=1.4.0.0, Culture=neutral" />
+    <Reference Include="Banshee.Services, Version=1.4.0.0, Culture=neutral" />
+    <Reference Include="Banshee.Services, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\..\..\bin\Banshee.Services.dll</HintPath>
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="Banshee.Core, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\..\..\bin\Banshee.Core.dll</HintPath>
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+    <Reference Include="Mono.Posix" />
+    <Reference Include="Banshee.ThickClient, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null">
+      <HintPath>..\..\..\bin\Banshee.ThickClient.dll</HintPath>
+      <SpecificVersion>False</SpecificVersion>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Banshee.PlayQueue\PlayQueueSource.cs" />
+    <Compile Include="Banshee.PlayQueue\PlayQueueActions.cs" />
+    <Compile Include="Banshee.PlayQueue\IPlayQueue.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="Resources\ActiveSourceUI.xml">
+      <LogicalName>ActiveSourceUI.xml</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Resources\GlobalUI.xml">
+      <LogicalName>GlobalUI.xml</LogicalName>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Banshee.PlayQueue.addin.xml" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <ProjectExtensions>
+    <MonoDevelop>
+      <Properties>
+        <GtkDesignInfo />
+        <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="true" RelativeMakefileName="./Makefile.am">
+          <BuildFilesVar Sync="true" Name="SOURCES" />
+          <DeployFilesVar />
+          <ResourcesVar Sync="true" Name="RESOURCES" />
+          <OthersVar />
+          <GacRefVar />
+          <AsmRefVar />
+          <ProjectRefVar />
+        </MonoDevelop.Autotools.MakefileInfo>
+      </Properties>
+    </MonoDevelop>
+  </ProjectExtensions>
 </Project>
\ No newline at end of file
Index: src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
===================================================================
--- src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs	(revision 4864)
+++ src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs	(working copy)
@@ -64,6 +64,20 @@
                     Catalog.GetString ("Clear the play queue when quitting"), 
                     OnClearPlayQueueOnQuit, PlayQueueSource.ClearOnQuitSchema.Get ())
             });
+					
+			Add (new ToggleActionEntry [] {
+                new ToggleActionEntry ("AutoDJAction", null,
+                    Catalog.GetString ("Auto DJ"), null,
+                    Catalog.GetString ("Add extra tracks when queue is empty"),
+                    OnAutoDJ, PlayQueueSource.AutoDJSchema.Get ())
+            });
+								
+            Add (new ActionEntry [] {
+                new ActionEntry ("RandomTracksAction", Stock.Add,
+                    Catalog.GetString ("Random Tracks"), null,
+                    Catalog.GetString ("Append random songs to the play queue"),
+                    OnRandomTracks)
+            });
             
             AddUiFromFile ("GlobalUI.xml");
 
@@ -100,6 +114,17 @@
             PlayQueueSource.ClearOnQuitSchema.Set (action.Active);
         }
 
+		private void OnRandomTracks (object o, EventArgs args)
+		{
+			playqueue.RandomTracks();
+		}						
+						
+		private void OnAutoDJ (object o, EventArgs args)
+		{
+	        ToggleAction action = this["AutoDJAction"] as Gtk.ToggleAction;
+			PlayQueueSource.AutoDJSchema.Set (action.Active);
+		}
+
         #endregion
 
         private void OnSourceUpdated (SourceEventArgs args)
Index: src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
===================================================================
--- src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(revision 4864)
+++ src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs	(working copy)
@@ -55,6 +55,7 @@
         private TrackInfo prior_playback_track;
         private PlayQueueActions actions;
         private bool was_playing = false;
+		private int track_count = 0;
         
         protected override bool HasArtistAlbum {
             get { return false; }
@@ -217,11 +218,18 @@
         {
             if (args.Event == PlayerEvent.EndOfStream) {
                 if (RemovePlayingTrack () && Count == 0) {
-                    if (was_playing) {
-                        ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
-                    } else {
-                        ServiceManager.PlaybackController.StopWhenFinished = true;
-                    }
+					if (AutoDJSchema.Get()) {
+						RandomTracks();
+						ServiceManager.PlaybackController.Next (false);
+					}
+					else
+					{
+	                    if (was_playing) {
+	                        ServiceManager.PlaybackController.PriorTrack = prior_playback_track;
+	                    } else {
+	                        ServiceManager.PlaybackController.StopWhenFinished = true;
+	                    }
+					}
                 }
             } else if (args.Event == PlayerEvent.StartOfStream) {
                 if (this == ServiceManager.PlaybackController.Source) {
@@ -232,6 +240,30 @@
                 }
             }
         }
+		
+		public void RandomTracks()
+		{
+			// Get the last track number
+			if(track_count==0)
+				track_count = ServiceManager.DbConnection.Query<int> ("SELECT MAX(TrackId) FROM CoreTracks");
+			// Add a new random track						
+			Random rnd = new Random();
+			int trackId = 0;
+			int tracks = 0;
+			while (trackId == 0 || tracks <5)
+			{
+				trackId = (int)(rnd.NextDouble() * track_count);
+				int trackExists = ServiceManager.DbConnection.Query<int> ("SELECT COUNT(*) FROM CoreTracks WHERE TrackId = ?", trackId);
+				// Track doesn't exist so try again
+				if (trackExists == 0)
+					trackId = 0;
+				else
+				{
+					EnqueueId(trackId, false);
+					tracks++;
+				}
+			}	
+		}
 
         bool IBasicPlaybackController.First ()
         {
@@ -310,5 +342,12 @@
             "Clear on Quit",
             "Clear the play queue when quitting"
         );
+		
+		public static readonly SchemaEntry<bool> AutoDJSchema = new SchemaEntry<bool> (
+            "plugins.play_queue", "auto_dj",
+            false,
+            "Auto DJ",
+            "Add extra tracks when queue is empty"
+        );
     }
 }
