From 38a033112c3e4e77e21e6d2d5899cfcb9bff07b0 Mon Sep 17 00:00:00 2001
From: sebastiii <sebastiii@team-mediaportal.com>
Date: Fri, 19 Feb 2016 06:52:32 +0100
Subject: [PATCH] WIP : WTV rework with MediaInfo.

---
 mediaportal/Core/Player/MediaInfoWrapper.cs | 21 +++++++++++++++++++++
 mediaportal/Core/Player/VideoPlayerVMR9.cs  |  3 ++-
 mediaportal/Core/Player/g_player.cs         | 13 +++----------
 3 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/mediaportal/Core/Player/MediaInfoWrapper.cs b/mediaportal/Core/Player/MediaInfoWrapper.cs
index a0ad76b..1c85de2 100644
--- a/mediaportal/Core/Player/MediaInfoWrapper.cs
+++ b/mediaportal/Core/Player/MediaInfoWrapper.cs
@@ -66,6 +66,8 @@ namespace MediaPortal.Player
     private bool _hasSubtitles = false;
     private static HashSet<string> _subTitleExtensions = new HashSet<string>();
 
+    private bool _mediaInfoNotloaded = false;
+
     #endregion
 
     #region ctor's
@@ -85,6 +87,7 @@ namespace MediaPortal.Player
     {
       if (!MediaInfoExist())
       {
+        _mediaInfoNotloaded = true;
         return;
       }
 
@@ -107,6 +110,14 @@ namespace MediaPortal.Player
         Log.Debug("MediaInfoWrapper: isTv:{0}, isRadio:{1}, isRTSP:{2}, isAVStream:{3}", isTV, isRadio, isRTSP,
                   isAVStream);
         Log.Debug("MediaInfoWrapper: disabled for this content");
+        _mediaInfoNotloaded = true;
+        return;
+      }
+
+      if (strFile.ToLowerInvariant().EndsWith(".wtv"))
+      {
+        Log.Debug("MediaInfoWrapper: WTV file is not handled");
+        _mediaInfoNotloaded = true;
         return;
       }
 
@@ -122,6 +133,7 @@ namespace MediaPortal.Player
       {
         Log.Debug("MediaInfoWrapper: isVideo:{0}, isDVD:{1}[enabled:{2}]", isVideo, isDVD, _DVDenabled);
         Log.Debug("MediaInfoWrapper: disabled for this content");
+        _mediaInfoNotloaded = true;
         return;
       }
 
@@ -139,7 +151,10 @@ namespace MediaPortal.Player
             strFile = Util.DaemonTools.GetVirtualDrive() + @"\BDMV\index.bdmv";
 
             if (!File.Exists(strFile))
+            {
+              _mediaInfoNotloaded = true;
               return;
+            }
           }
         }
         
@@ -175,6 +190,7 @@ namespace MediaPortal.Player
         }
         else
         {
+          _mediaInfoNotloaded = true;
           return;
         }
 
@@ -602,6 +618,11 @@ namespace MediaPortal.Player
       get { return _hasSubtitles; }
     }
 
+    public bool MediaInfoNotloaded
+    {
+      get { return _mediaInfoNotloaded; }
+    }
+
     #endregion
   }
 }
\ No newline at end of file
diff --git a/mediaportal/Core/Player/VideoPlayerVMR9.cs b/mediaportal/Core/Player/VideoPlayerVMR9.cs
index 11134da..bb5f20b 100644
--- a/mediaportal/Core/Player/VideoPlayerVMR9.cs
+++ b/mediaportal/Core/Player/VideoPlayerVMR9.cs
@@ -548,7 +548,8 @@ namespace MediaPortal.Player
         // after enabeling exclusive mode, if done first it causes MediPortal to minimize if for example the "Windows key" is pressed while playing a video
         if (File.Exists(m_strCurrentFile) && extension != ".dts" && extension != ".mp3" && extension != ".mka" && extension != ".ac3")
         {
-          if (g_Player._mediaInfo != null && !g_Player._mediaInfo.hasVideo)
+          if (g_Player._mediaInfo != null && (g_Player._mediaInfo != null && !g_Player._mediaInfo.hasVideo &&
+                                              (extension.ToLowerInvariant() != ".wtv" && g_Player._mediaInfo.MediaInfoNotloaded)))
           {
             AudioOnly = true;
           }
diff --git a/mediaportal/Core/Player/g_player.cs b/mediaportal/Core/Player/g_player.cs
index 1b46e23..89b562a 100644
--- a/mediaportal/Core/Player/g_player.cs
+++ b/mediaportal/Core/Player/g_player.cs
@@ -1514,9 +1514,9 @@ namespace MediaPortal.Player
         {
           if (currentMediaInfoFilePlaying != strFile)
           {
-          _mediaInfo = new MediaInfoWrapper(strFile);
+            _mediaInfo = new MediaInfoWrapper(strFile);
             currentMediaInfoFilePlaying = strFile;
-        }
+          }
         }
 
         // back to previous Windows if we are only in video fullscreen to do a proper release when next item is music only
@@ -1637,14 +1637,7 @@ namespace MediaPortal.Player
             IsExtTS = true;
           }
           // Set bool to know if video if we force play
-          if (forcePlay)
-          {
-            ForcePlay = true;
-          }
-          else
-          {
-            ForcePlay = false;
-          }
+          ForcePlay = forcePlay;
         }
 
         // Set currentMedia needed for correct detection when BASS Engine is doing a Stop
-- 
2.6.3.windows.1

