Skip to content

Commit

Permalink
WMP fallback mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Brhsoftco committed Sep 22, 2020
1 parent 6fd3cf6 commit d133709
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 58 deletions.
12 changes: 12 additions & 0 deletions PlexDL.Common.Components/DXPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Windows.Forms;

namespace PlexDL.Common.Components
{
public class DXPanel : Panel
{
public DXPanel()
{
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
}
}
}
3 changes: 3 additions & 0 deletions PlexDL.Common.Components/PlexDL.Common.Components.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
<Compile Include="CircularProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="DXPanel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="FlatDataGridView.cs">
<SubType>Component</SubType>
</Compile>
Expand Down
4 changes: 4 additions & 0 deletions PlexDL.Common/Structures/AppOptions/Player/PlayerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class PlayerSettings
"[3] - MenuSelector")]
public PlaybackMode PlaybackEngine { get; set; } = PlaybackMode.MenuSelector;

[DisplayName("Force Windows Media Player Mode")]
[Description("If you're having trouble with PVS, you can force PlexDL to use the native Windows Media Player COM library (wmp.dll)")]
public bool ForceWmpMode { get; set; } = false;

// to make sure the PropertyGrid doesn't keep showing the name of this class, just return a blank string.
public override string ToString()
{
Expand Down
20 changes: 10 additions & 10 deletions PlexDL/PlexDL.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Net" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows" />
<Reference Include="System.Xaml" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down Expand Up @@ -317,7 +316,16 @@
<ItemGroup>
<WCFMetadata Include="Connected Services\" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<COMReference Include="AxWMPLib">
<Guid>{6BF52A50-394A-11D3-B153-00C04F79FAA6}</Guid>
<VersionMajor>1</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>aximp</WrapperTool>
<Isolated>False</Isolated>
</COMReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
Expand All @@ -331,10 +339,6 @@
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitHubUpdater\GitHubUpdater.csproj">
<Project>{9e90936d-f2b8-4ad6-940a-11178ae67082}</Project>
<Name>GitHubUpdater</Name>
</ProjectReference>
<ProjectReference Include="..\inet\inet.csproj">
<Project>{6423075d-fb6a-4a21-b8c3-2bdb02d3e744}</Project>
<Name>inet</Name>
Expand All @@ -359,10 +363,6 @@
<Project>{1764ca80-f851-4e2c-acc8-37696d499d3b}</Project>
<Name>PlexDL.Common.Pxz</Name>
</ProjectReference>
<ProjectReference Include="..\PlexDL.Common.Security\PlexDL.Common.Security.csproj">
<Project>{aba08e30-bcbb-4eb8-a187-8c8b7037bc48}</Project>
<Name>PlexDL.Common.Security</Name>
</ProjectReference>
<ProjectReference Include="..\PlexDL.Common\PlexDL.Common.csproj">
<Project>{a464f174-fedd-45c7-b17a-4fd707867f2b}</Project>
<Name>PlexDL.Common</Name>
Expand Down
70 changes: 42 additions & 28 deletions PlexDL/UI/Player.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 37 additions & 18 deletions PlexDL/UI/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,59 @@
using System.Windows.Forms;
using UIHelpers;

#pragma warning disable 1591

namespace PlexDL.UI
{
public partial class Player : Form
{
private PlexDL.Player.Player _mPlayer;
public bool CanFadeOut = true;

public bool IsWmp = false;
private bool _isWmp = ObjectProvider.Settings.Player.ForceWmpMode;

public Timer T1 = new Timer();
public PlexObject StreamingContent { get; set; }

public Player()
{
InitializeComponent();
}

//double-buffering override for the entire form
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
var cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}

private void SwitchWmp(bool pvsSetup = true)
{
//PVS
tlpMaster.Enabled = !_isWmp;
tlpMaster.Visible = !_isWmp;

//WMP COM
wmpMain.Enabled = _isWmp;
wmpMain.Visible = _isWmp;

//PVS setup
if (!_isWmp && pvsSetup)
{
_mPlayer = new PlexDL.Player.Player(pnlPlayer);
_mPlayer.Sliders.Position.TrackBar = trkDuration;
_mPlayer.Events.MediaPositionChanged += MPlayer_MediaPositionChanged;
_mPlayer.Events.MediaEnded += MPlayer_ContentFinished;
_mPlayer.Events.MediaStarted += MPlayer_ContentStarted;
}
else if (_isWmp)
{
wmpMain.URL = StreamingContent.StreamInformation.Links.View;
}
}

private void FrmPlayer_Load(object sender, EventArgs e)
{
var formTitle = StreamingContent.StreamInformation.ContentTitle;
Expand All @@ -49,15 +75,13 @@ private void FrmPlayer_Load(object sender, EventArgs e)
if (!PlexDL.Player.Player.MFPresent)
{
UIMessages.Error(
@"MediaFoundation is not installed. The player will not be able to stream the selected content :(",
@"MediaFoundation is not installed. The player will not be able to stream the selected content; reverting to WMP mode.",
@"Playback Error");
CanFadeOut = false;
Close();
_isWmp = true;
}

if (StreamingContent.StreamInformation.Container == "mkv")
{
CanFadeOut = false;
var msg =
UIMessages.Question(
@"PlexDL Matroska (mkv) playback is not supported. Would you like to open the file in VLC Media Player? Note: It must already be installed");
Expand All @@ -79,11 +103,8 @@ private void FrmPlayer_Load(object sender, EventArgs e)
Close();
}

_mPlayer = new PlexDL.Player.Player(pnlPlayer);
_mPlayer.Sliders.Position.TrackBar = trkDuration;
_mPlayer.Events.MediaPositionChanged += MPlayer_MediaPositionChanged;
_mPlayer.Events.MediaEnded += MPlayer_ContentFinished;
_mPlayer.Events.MediaStarted += MPlayer_ContentStarted;
//decide appropriate player
SwitchWmp();

//UIMessages.Info(TitlesTable.Rows.Count + "\n" +StreamingContent.StreamIndex);
//UIMessages.Info("Duration: "+StreamingContent.ContentDuration+"\nSize: "+StreamingContent.ByteLength);
Expand All @@ -100,7 +121,8 @@ private void FrmPlayer_Load(object sender, EventArgs e)

protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (IsWmp) return base.ProcessCmdKey(ref msg, keyData);
//hotkeys are disabled during Windows Media Player mode
if (_isWmp) return base.ProcessCmdKey(ref msg, keyData);

if (keyData == ObjectProvider.Settings.Player.KeyBindings.PlayPause)
{
Expand Down Expand Up @@ -143,12 +165,9 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
return base.ProcessCmdKey(ref msg, keyData);
}

private void FrmPlayer_Resize(object sender, EventArgs e)
{
}

private void FrmPlayer_FormClosing(object sender, FormClosingEventArgs e)
{
wmpMain?.Dispose();
_mPlayer?.Dispose();
}

Expand Down
11 changes: 11 additions & 0 deletions PlexDL/UI/Player.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>55</value>
</metadata>
<data name="wmpMain.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB
AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA
AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAZgB1AGwAbAAAAAsA
AAALAAAACwD//wsAAAALAP//CAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAAS4QAAK9P
AAAL
</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
2 changes: 0 additions & 2 deletions PlexDL/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="libbrhscgui" version="1.0.0" targetFramework="net472" />
<package id="Sharpcaster.SocketsForPCL" version="2.0.4" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net472" />
</packages>

0 comments on commit d133709

Please sign in to comment.