Index: libs/libmyth/mythmedia.cpp
===================================================================
--- libs/libmyth/mythmedia.cpp	(revision 7227)
+++ libs/libmyth/mythmedia.cpp	(working copy)
@@ -7,6 +7,7 @@
 
 // Qt Headers
 #include <qfile.h>
+#include <qdir.h>
 
 // MythTV headers
 #include "mythmedia.h"
@@ -38,7 +39,10 @@
     "MEDIATYPE_MIXED",
     "MEDIATYPE_AUDIO",
     "MEDIATYPE_DVD",
-    "MEDIATYPE_VCD"
+    "MEDIATYPE_VCD",
+    "MEDIATYPE_MMUSIC",
+    "MEDIATYPE_MVIDEO",
+    "MEDIATYPE_MGALLERY"
 };
 
 const char* MythMediaDevice::MediaErrorStrings[] =
@@ -109,6 +113,7 @@
             {
                 m_Status = MEDIASTAT_MOUNTED;
                 onDeviceMounted();
+                DetectMediaType();
             }
             else
                 onDeviceUnmounted();
@@ -122,12 +127,15 @@
     } 
     else 
     {
-        VERBOSE( VB_ALL,  "Disk iserted on a supermount device" );
+        VERBOSE( VB_ALL,  "Disk inserted on a supermount device" );
         // If it's a super mount then the OS will handle mounting /  unmounting.
         // We just need to give derived classes a chance to perform their 
         // mount / unmount logic.
         if (DoMount)
+        {
             onDeviceMounted();
+            DetectMediaType();
+        }
         else
             onDeviceUnmounted();
         return true;
@@ -243,3 +251,101 @@
     return m_Status;
 }
 
+
+//
+// Try to make an educated guess about the type of data present on the Media.
+// This fuction changes m_MediaType accordingly.
+//
+void MythMediaDevice::DetectMediaType(void)
+{
+
+    ScanMediaType(m_MountPath);
+    if (ExtensionArray.isEmpty ())
+    {
+        VERBOSE(VB_GENERAL,
+           QString("No files with extension found in '%1'").arg (m_MountPath));
+    } else {
+        int  score = 0, highscore = 0, type = 0;
+
+        ExtensionMap *em;
+        for (em = ExtensionMapList.first(); em; em = ExtensionMapList.next())
+        {
+            QStringList::Iterator it;
+            for (it = em->Extensions.begin(); it != em->Extensions.end(); ++it)
+            {
+                if (ExtensionArray.contains(*it))
+                    score += ExtensionArray[*it];
+            }
+            VERBOSE(VB_ALL, QString("Looking for: '%1', Score: %2")
+                   .arg(MediaTypeStrings[ffs(em->Mediatype)])
+                   .arg(score));
+            if (score > highscore)
+                type = em->Mediatype; highscore = score;
+        }
+        if (type != 0)
+            m_MediaType = (MediaType)type;
+    }
+    ExtensionArray.clear();
+}
+
+//
+// Recursively scan directories and create an associative array with
+// key: 'tolower(extension)' and value the number of times we've
+// seen it.
+//
+void MythMediaDevice::ScanMediaType(const QString& directory)
+{
+    QDir d(directory);
+
+    d.setSorting(QDir::DirsFirst | QDir::Name | QDir::IgnoreCase);
+    if (!d.exists())
+            return;
+
+    const QFileInfoList *list = d.entryInfoList();
+    if (!list)                        
+        return;
+
+    QFileInfoListIterator it(*list);
+    QFileInfo *fi;
+
+    while ((fi = it.current()) != 0)
+    {
+        ++it;
+        if (fi->fileName() == "." || fi->fileName() == ".." )
+                continue;
+        if (!fi->isDir())
+        {
+            QString extension = fi->extension(false);
+            if (!extension.isEmpty())
+            {
+                extension = extension.lower();
+                if (ExtensionArray.contains(extension))
+                    ExtensionArray[extension]++;
+                else
+                    ExtensionArray[extension] = 1;
+            }
+        }
+        else ScanMediaType(fi->absFilePath());
+    }
+}
+
+//
+// Allow Plugin's to register their supported MediaType and the file
+// extensions that map to it.
+// The extensions argument is a comma separated list of extensions like:
+//    'mp3,ogg,flac'.
+//
+void MythMediaDevice::MediaRegisterExtensions(const int mediatype, const QString& extensions)
+{
+    ExtensionMap *eMap = new ExtensionMap;
+    eMap->Mediatype  = mediatype;
+    eMap->Extensions = QStringList::split(",", extensions, "");
+
+    if (eMap->Extensions.count() == 0)
+    {
+        cerr << "Empty setting for entry: " << mediatype << endl;
+        delete eMap;
+        return;
+    }
+    ExtensionMapList.append(eMap);
+}
Index: libs/libmyth/mythmediamonitor.h
===================================================================
--- libs/libmyth/mythmediamonitor.h	(revision 7227)
+++ libs/libmyth/mythmediamonitor.h	(working copy)
@@ -57,6 +57,7 @@
     void checkDevices(void);
     void startMonitoring(void);
     void stopMonitoring(void);
+    void MonitorRegisterExtensions(int mediaType, const QString &extensions);
     QValueList <MythMediaDevice*> getMedias(MediaType mediatype);
     
     static MediaMonitor* getMediaMonitor();
Index: libs/libmyth/mythdialogs.cpp
===================================================================
--- libs/libmyth/mythdialogs.cpp	(revision 7227)
+++ libs/libmyth/mythdialogs.cpp	(working copy)
@@ -660,7 +660,8 @@
                                           const QString &description,
                                           const QString &key, 
                               void (*callback)(MythMediaDevice*mediadevice),
-                                          int mediaType)
+                                          int mediaType,
+                                          const QString &extensions)
 {
     (void)key;
 
@@ -672,6 +673,17 @@
                                    .arg(destination));
 
         d->mediaHandlerMap[destination] = mhd;
+        if (extensions != NULL)
+        {
+            MediaMonitor *mon = MediaMonitor::getMediaMonitor();
+            if (mon == NULL)
+            {
+                cerr << "MythMainWindow::RegisterMediaHandler: " <<
+                        "Cannot get to MediaMonitor" << endl;
+            } else {
+                mon->MonitorRegisterExtensions(mediaType, extensions);
+            }
+        }
     }
     else 
     {
Index: libs/libmyth/mythmediamonitor.cpp
===================================================================
--- libs/libmyth/mythmediamonitor.cpp	(revision 7227)
+++ libs/libmyth/mythmediamonitor.cpp	(working copy)
@@ -306,6 +306,24 @@
     m_Thread.wait();
 }
 
+//
+// Register the extension list on all known devices
+//
+void MediaMonitor::MonitorRegisterExtensions(int mediaType,
+                                             const QString &extensions)
+{
+    QValueList<MythMediaDevice*>::iterator itr = m_Devices.begin();
+    MythMediaDevice* pDev;
+    while (itr != m_Devices.end()) 
+    {
+        pDev = *itr;
+        if (pDev)
+            pDev->MediaRegisterExtensions(mediaType,extensions);
+        itr++;
+    }
+
+}
+//
 // Ask for available media
 QValueList <MythMediaDevice*> MediaMonitor::getMedias(MediaType mediatype)
 {
Index: libs/libmyth/mythdialogs.h
===================================================================
--- libs/libmyth/mythdialogs.h	(revision 7227)
+++ libs/libmyth/mythdialogs.h	(working copy)
@@ -60,7 +60,7 @@
 
 #define REG_KEY(a, b, c, d) gContext->GetMainWindow()->RegisterKey(a, b, c, d)
 #define REG_JUMP(a, b, c, d) gContext->GetMainWindow()->RegisterJump(a, b, c, d)
-#define REG_MEDIA_HANDLER(a, b, c, d, e) gContext->GetMainWindow()->RegisterMediaHandler(a, b, c, d, e)
+#define REG_MEDIA_HANDLER(a, b, c, d, e, f) gContext->GetMainWindow()->RegisterMediaHandler(a, b, c, d, e, f)
 #define REG_MEDIAPLAYER(a,b,c) gContext->GetMainWindow()->RegisterMediaPlugin(a, b, c)
 
 typedef  int (*MediaPlayCallback)(const char*, const char*, const char*, const char*, int, const char*);
@@ -98,7 +98,8 @@
     void RegisterMediaHandler(const QString &destination, 
                               const QString &description, const QString &key, 
                               void (*callback)(MythMediaDevice* mediadevice), 
-                              int mediaType);
+                              int mediaType,
+                              const QString &extensions);
 
     void RegisterMediaPlugin(const QString &name, const QString &desc,
                              MediaPlayCallback fn);
Index: libs/libmyth/mythmedia.h
===================================================================
--- libs/libmyth/mythmedia.h	(revision 7227)
+++ libs/libmyth/mythmedia.h	(working copy)
@@ -3,6 +3,7 @@
 
 #include <qobject.h>
 #include <qstring.h>
+#include <qstringlist.h>
 
 typedef enum {
     MEDIASTAT_ERROR,
@@ -19,7 +20,10 @@
     MEDIATYPE_MIXED=4,
     MEDIATYPE_AUDIO=8,
     MEDIATYPE_DVD=16,
-    MEDIATYPE_VCD=32
+    MEDIATYPE_VCD=32,
+    MEDIATYPE_MMUSIC=64,
+    MEDIATYPE_MVIDEO=128,
+    MEDIATYPE_MGALLERY=256
 } MediaType;
 
 typedef enum {
@@ -73,6 +77,9 @@
     bool mount() {  return performMountCmd(true); }
     bool unmount() { return performMountCmd(false); }
     bool isMounted(bool bVerify = false);
+
+    void MediaRegisterExtensions(const int mediatype,const QString& extensions);
+
     
     static const char* MediaStatusStrings[];
     static const char* MediaTypeStrings[];
@@ -86,6 +93,8 @@
     virtual void onDeviceMounted() {};
     virtual void onDeviceUnmounted() {};
 
+    void DetectMediaType(void);
+    void ScanMediaType(const QString& directory);
     MediaStatus setStatus(MediaStatus newStat, bool CloseIt=false);
 
     QString m_MountPath;        ///< The path to this media's mount point (i.e. /mnt/cdrom). Read only.
@@ -99,6 +108,13 @@
     int m_DeviceHandle;         ///< A file handle for opening and closing the device.
     MediaType m_MediaType;      ///< The type of media
     bool m_SuperMount;          ///< Is this a supermount device?
+    QMap<QString, int> ExtensionArray; ///< current tally of extensions on the disk
+    typedef struct {
+        int         Mediatype;
+        QStringList Extensions;
+    } ExtensionMap;
+    QPtrList<ExtensionMap> ExtensionMapList; ///< Map extansions to a mediatype
+
 };
 
 #endif
