From bb82d1ed28aa1d50c0104da18216a5eb5c11dccb Mon Sep 17 00:00:00 2001
From: Sebastiii <sebastiii@team-mediaportal.com>
Date: Wed, 1 Jun 2016 13:17:27 +0200
Subject: [PATCH] WIP OV Sebastiii : Upgrade Bump version for madVR. WIP OV
 Sebastiii : remove illegal character when download video and change handle
 for madVR. WIP OV Sebastiii : madVR and build.

---
 MPEI/OnlineVideos.xmp2                             | 16 +++---
 OnlineVideos.MediaPortal1/GUIOnlineVideos.cs       | 10 +++-
 .../Player/OnlineVideosPlayer.cs                   | 65 +++++++++++-----------
 .../Properties/AssemblyInfo.cs                     |  2 +-
 4 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/MPEI/OnlineVideos.xmp2 b/MPEI/OnlineVideos.xmp2
index f5765d4..e27e8fd 100644
--- a/MPEI/OnlineVideos.xmp2
+++ b/MPEI/OnlineVideos.xmp2
@@ -2376,28 +2376,28 @@
             <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
               <Param1 />
               <UpdateOption>AlwaysOverwrite</UpdateOption>
-              <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos.MediaPortal1.dll</LocalFileName>
+              <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos.MediaPortal1.dll</LocalFileName>
               <ZipFileName>Installer{CopyFile}\{c795f3a7-881d-4376-b2a2-e8ac9eec9eaa}-OnlineVideos.MediaPortal1.dll</ZipFileName>
               <DestinationFilename>%Plugins%\Windows\OnlineVideos.MediaPortal1.dll</DestinationFilename>
             </FileItem>
             <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
               <Param1 />
               <UpdateOption>AlwaysOverwrite</UpdateOption>
-              <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.dll</LocalFileName>
+              <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.dll</LocalFileName>
               <ZipFileName>Installer{CopyFile}\{acc12d0d-7e32-4ca4-8385-c6cff6c8b321}-OnlineVideos.dll</ZipFileName>
               <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.dll</DestinationFilename>
             </FileItem>
             <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
               <Param1 />
               <UpdateOption>AlwaysOverwrite</UpdateOption>
-              <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</LocalFileName>
+              <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</LocalFileName>
               <ZipFileName>Installer{CopyFile}\{453f6e32-54d5-49c0-af60-cd08a14c386d}-OnlineVideos.WebAutomation.BrowserHost.exe</ZipFileName>
               <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</DestinationFilename>
             </FileItem>
             <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
               <Param1 />
               <UpdateOption>AlwaysOverwrite</UpdateOption>
-              <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</LocalFileName>
+              <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</LocalFileName>
               <ZipFileName>Installer{CopyFile}\{0e030923-323c-4964-9e9b-05806a4fac5c}-OnlineVideos.WebAutomation.BrowserHost.exe.config</ZipFileName>
               <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</DestinationFilename>
             </FileItem>
@@ -6093,28 +6093,28 @@ BrowserPlayer changes to support MediaPortal2</VersionDescription>
       <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
         <Param1 />
         <UpdateOption>AlwaysOverwrite</UpdateOption>
-        <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos.MediaPortal1.dll</LocalFileName>
+        <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos.MediaPortal1.dll</LocalFileName>
         <ZipFileName>Installer{CopyFile}\{c795f3a7-881d-4376-b2a2-e8ac9eec9eaa}-OnlineVideos.MediaPortal1.dll</ZipFileName>
         <DestinationFilename>%Plugins%\Windows\OnlineVideos.MediaPortal1.dll</DestinationFilename>
       </FileItem>
       <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
         <Param1 />
         <UpdateOption>AlwaysOverwrite</UpdateOption>
-        <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.dll</LocalFileName>
+        <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.dll</LocalFileName>
         <ZipFileName>Installer{CopyFile}\{acc12d0d-7e32-4ca4-8385-c6cff6c8b321}-OnlineVideos.dll</ZipFileName>
         <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.dll</DestinationFilename>
       </FileItem>
       <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
         <Param1 />
         <UpdateOption>AlwaysOverwrite</UpdateOption>
-        <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</LocalFileName>
+        <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</LocalFileName>
         <ZipFileName>Installer{CopyFile}\{453f6e32-54d5-49c0-af60-cd08a14c386d}-OnlineVideos.WebAutomation.BrowserHost.exe</ZipFileName>
         <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe</DestinationFilename>
       </FileItem>
       <FileItem InstallType="CopyFile" SystemFile="false" Modified="true">
         <Param1 />
         <UpdateOption>AlwaysOverwrite</UpdateOption>
-        <LocalFileName>..\..\..\..\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</LocalFileName>
+        <LocalFileName>c:\Program Files (x86)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</LocalFileName>
         <ZipFileName>Installer{CopyFile}\{0e030923-323c-4964-9e9b-05806a4fac5c}-OnlineVideos.WebAutomation.BrowserHost.exe.config</ZipFileName>
         <DestinationFilename>%Plugins%\Windows\OnlineVideos\OnlineVideos.WebAutomation.BrowserHost.exe.config</DestinationFilename>
       </FileItem>
diff --git a/OnlineVideos.MediaPortal1/GUIOnlineVideos.cs b/OnlineVideos.MediaPortal1/GUIOnlineVideos.cs
index d4b1652..6cc1a29 100644
--- a/OnlineVideos.MediaPortal1/GUIOnlineVideos.cs
+++ b/OnlineVideos.MediaPortal1/GUIOnlineVideos.cs
@@ -2685,9 +2685,15 @@ namespace OnlineVideos.MediaPortal1
             }
 
             saveItems.CurrentItem.Url = url;
-            if (string.IsNullOrEmpty(saveItems.CurrentItem.Title)) saveItems.CurrentItem.Title = saveItems.CurrentItem.VideoInfo.Title;
+          if (string.IsNullOrEmpty(saveItems.CurrentItem.Title))
+          {
+            saveItems.CurrentItem.Title = saveItems.CurrentItem.VideoInfo.Title;
+            saveItems.CurrentItem.Title = Regex.Replace(saveItems.CurrentItem.Title, @"\s|\-|:", "");
+          }
 
-            if (!string.IsNullOrEmpty(saveItems.CurrentItem.OverrideFolder))
+          saveItems.CurrentItem.VideoInfo.Title = Regex.Replace(saveItems.CurrentItem.VideoInfo.Title, @"\s|\-|:", "");
+
+          if (!string.IsNullOrEmpty(saveItems.CurrentItem.OverrideFolder))
             {
                 if (!string.IsNullOrEmpty(saveItems.CurrentItem.OverrideFileName))
                     saveItems.CurrentItem.LocalFile = Path.Combine(saveItems.CurrentItem.OverrideFolder, saveItems.CurrentItem.OverrideFileName);
diff --git a/OnlineVideos.MediaPortal1/Player/OnlineVideosPlayer.cs b/OnlineVideos.MediaPortal1/Player/OnlineVideosPlayer.cs
index 279fd23..c481420 100644
--- a/OnlineVideos.MediaPortal1/Player/OnlineVideosPlayer.cs
+++ b/OnlineVideos.MediaPortal1/Player/OnlineVideosPlayer.cs
@@ -53,7 +53,7 @@ namespace OnlineVideos.MediaPortal1.Player
                             RefreshRateHelper.ChangeRefreshRateToMatchedFps(matchedFps, cacheFile);
                             try
                             {
-                                if (GUIGraphicsContext.IsEvr)
+                              if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR)
                                     EVRUpdateDisplayFPS();
                             }
                             catch (EntryPointNotFoundException)
@@ -88,7 +88,7 @@ namespace OnlineVideos.MediaPortal1.Player
 
         void AdaptRefreshRateFromVideoRenderer()
         {
-            if (GUIGraphicsContext.IsEvr)
+          if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR)
             {
                 if (!refreshRateAdapted && m_state == PlayState.Playing)
                 {
@@ -245,6 +245,8 @@ namespace OnlineVideos.MediaPortal1.Player
                 graphBuilder = (IGraphBuilder)new FilterGraph();
                 _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder);
 
+                basicVideo = graphBuilder as IBasicVideo2;
+
                 Vmr9 = new VMR9Util();
                 Vmr9.AddVMR9(graphBuilder);
                 Vmr9.Enable(false);
@@ -690,44 +692,40 @@ namespace OnlineVideos.MediaPortal1.Player
             }
             if (videoWin != null)
             {
-                videoWin.put_Owner(GUIGraphicsContext.ActiveForm);
-                videoWin.put_WindowStyle(
-                  (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipChildren + (int)WindowStyle.ClipSiblings));
+                videoWin.put_WindowStyle((WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipChildren + (int)WindowStyle.ClipSiblings));
                 videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle);
             }
-            if (basicVideo != null)
-            {
-                hr = basicVideo.GetVideoSize(out m_iVideoWidth, out m_iVideoHeight);
-                if (hr < 0)
-                {
-                    Error.SetError("Unable to play movie", "Can not find movie width/height");
-                    m_strCurrentFile = "";
-                    CloseInterfaces();
-                    return false;
-                }
-            }
 
             DirectShowUtil.SetARMode(graphBuilder, AspectRatioMode.Stretched);
 
             try
             {
-                hr = mediaCtrl.Run();
-                DsError.ThrowExceptionForHR(hr);
-                if (hr == 1) // S_FALSE from IMediaControl::Run means: The graph is preparing to run, but some filters have not completed the transition to a running state.
+                if (protocol == "file")
                 {
-                    // wait max. 20 seconds for the graph to transition to the running state
-                    DateTime startTime = DateTime.Now;
-                    FilterState filterState;
-                    do
-                    {
-                        Thread.Sleep(100);
-                        hr = mediaCtrl.GetState(100, out filterState); // check with timeout max. 10 times a second if the state changed
-                    }
-                    while ((hr != 0) && ((DateTime.Now - startTime).TotalSeconds <= 20));
-                    if (hr != 0) // S_OK
+                    if (Vmr9 != null) Vmr9.StartMediaCtrl(mediaCtrl);
+                }
+                else
+                {
+                    hr = mediaCtrl.Run();
+                    DsError.ThrowExceptionForHR(hr);
+                    if (hr == 1)
+                        // S_FALSE from IMediaControl::Run means: The graph is preparing to run, but some filters have not completed the transition to a running state.
                     {
-                        DsError.ThrowExceptionForHR(hr);
-                        throw new Exception(string.Format("IMediaControl.GetState after 20 seconds: 0x{0} - '{1}'", hr.ToString("X8"), DsError.GetErrorText(hr)));
+                        // wait max. 20 seconds for the graph to transition to the running state
+                        DateTime startTime = DateTime.Now;
+                        FilterState filterState;
+                        do
+                        {
+                            Thread.Sleep(100);
+                            hr = mediaCtrl.GetState(100, out filterState);
+                            // check with timeout max. 10 times a second if the state changed
+                        } while ((hr != 0) && ((DateTime.Now - startTime).TotalSeconds <= 20));
+                        if (hr != 0) // S_OK
+                        {
+                            DsError.ThrowExceptionForHR(hr);
+                            throw new Exception(string.Format("IMediaControl.GetState after 20 seconds: 0x{0} - '{1}'",
+                                hr.ToString("X8"), DsError.GetErrorText(hr)));
+                        }
                     }
                 }
             }
@@ -743,6 +741,11 @@ namespace OnlineVideos.MediaPortal1.Player
                 return false;
             }
 
+            if (basicVideo != null)
+            {
+              basicVideo.GetVideoSize(out m_iVideoWidth, out m_iVideoHeight);
+            }
+
             if (GoFullscreen) GUIWindowManager.ActivateWindow(GUIOnlineVideoFullscreen.WINDOW_FULLSCREEN_ONLINEVIDEO);
             GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null);
             msg.Label = CurrentFile;
diff --git a/OnlineVideos.MediaPortal1/Properties/AssemblyInfo.cs b/OnlineVideos.MediaPortal1/Properties/AssemblyInfo.cs
index 638ee99..3357ee6 100644
--- a/OnlineVideos.MediaPortal1/Properties/AssemblyInfo.cs
+++ b/OnlineVideos.MediaPortal1/Properties/AssemblyInfo.cs
@@ -18,7 +18,7 @@ using MediaPortal.Common.Utils;
 [assembly: Guid("09b42e26-4a7f-46a7-b0a9-adda8a5099b0")]
 
 // Define that our plugin is designed for MediaPortal 1.7 - the MP dlls have been slightly restructured and it's using .net 4 now, so not backward compatible
-[assembly: CompatibleVersion("1.6.100.0", "1.6.100.0")]
+[assembly: CompatibleVersion("1.15.100.0", "1.15.100.0")]
 
 // Tell MediaPortal which subsystems this plugin will use, so it can check for compatiblity
 [assembly: UsesSubsystem("MP.SkinEngine")]
-- 
2.10.0.windows.1

