Skip to content

Commit

Permalink
various fixes (#232)
Browse files Browse the repository at this point in the history
* default args in settings

close #231

* no media player fixed

close #217
  • Loading branch information
jwallet committed Jan 12, 2019
1 parent 8cdcf94 commit 6fd0de3
Show file tree
Hide file tree
Showing 6 changed files with 532 additions and 460 deletions.
901 changes: 453 additions & 448 deletions NHLGames/NHLGamesMetro.Designer.vb

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions NHLGames/NHLGamesMetro.resx
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@
<metadata name="tmr.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>225, 17</value>
</metadata>
<metadata name="tt.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>296, 17</value>
</metadata>
<metadata name="fbd.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>155, 17</value>
</metadata>
Expand Down
45 changes: 42 additions & 3 deletions NHLGames/NHLGamesMetro.vb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,15 @@ Public Class NHLGamesMetro
Dim rb As RadioButton = sender
If rb.Checked Then
Player.RenewArgs()
Dim gameArgs = ApplicationSettings.Read(Of GameWatchArguments)(SettingsEnum.DefaultWatchArgs, New GameWatchArguments)
Dim defaultPlayerArgs = New Dictionary(Of String, String)()
Select Case gameArgs.PlayerType
Case PlayerTypeEnum.Vlc
defaultPlayerArgs = GameWatchArguments.VlcDefaultArgs
Case PlayerTypeEnum.Mpv
defaultPlayerArgs = GameWatchArguments.MpvDefaultArgs
End Select
SetDefaultArgs(defaultPlayerArgs, txtPlayerArgs, True)
_writeToConsoleSettingsChanged(lblPlayer.Text, rb.Text)
End If
End Sub
Expand Down Expand Up @@ -324,13 +333,15 @@ Public Class NHLGamesMetro
End Sub

Private Sub tgStreamer_CheckedChanged(sender As Object, e As EventArgs) Handles tgStreamer.CheckedChanged
SetStreamerDefaultArgs(FormInstance)
txtStreamerArgs.Enabled = tgStreamer.Checked
Player.RenewArgs()
_writeToConsoleSettingsChanged(String.Format(English.msgThisEnable, lblStreamerArgs.Text),
If(tgStreamer.Checked, English.msgOn, English.msgOff))
End Sub

Private Sub tgPlayer_CheckedChanged(sender As Object, e As EventArgs) Handles tgPlayer.CheckedChanged
SetPlayerDefaultArgs(FormInstance)
txtPlayerArgs.Enabled = tgPlayer.Checked
Player.RenewArgs()
_writeToConsoleSettingsChanged(String.Format(English.msgThisEnable, lblPlayerArgs.Text),
Expand Down Expand Up @@ -390,6 +401,34 @@ Public Class NHLGamesMetro
RefreshFocus()
End Sub

Public Sub SetStreamerDefaultArgs(form As NHLGamesMetro)
If form Is Nothing Then Return
If Not form.tgStreamer.Checked Then
SetDefaultArgs(GameWatchArguments.StreamerDefaultArgs, form.txtStreamerArgs)
End If
End Sub

Public Sub SetPlayerDefaultArgs(form As NHLGamesMetro, Optional overwrite As Boolean = False)
If form Is Nothing Then Return
If Not form.tgPlayer.Checked Then
Dim defaultArgs = New Dictionary(Of String, String)()
If form.rbMPV.Checked Then
defaultArgs = GameWatchArguments.MpvDefaultArgs
ElseIf form.rbVLC.Checked Then
defaultArgs = GameWatchArguments.VlcDefaultArgs
End If

SetDefaultArgs(defaultArgs, form.txtPlayerArgs, overwrite)
End If
End Sub

Private Sub SetDefaultArgs(args As Dictionary(Of String, String), txt As TextBox, Optional overwrite As Boolean = False)
If overwrite Then txt.Text = ""
For Each arg In args
If Not txt.Text.Contains(arg.Key) Then txt.Text &= $" {arg.Key}={arg.Value}"
Next
End Sub

Private Sub NHLGamesMetro_MouseMove(sender As Object, e As MouseEventArgs) Handles MyBase.MouseMove
_resizeDirection = -1
If e.Location.X < ResizeBorderWidth And e.Location.Y < ResizeBorderWidth Then
Expand Down Expand Up @@ -622,9 +661,9 @@ Public Class NHLGamesMetro
Dim report = $"NHLGames Bug Report {version}{vbCrLf}{vbCrLf}" &
$"Operating system: {My.Computer.Info.OSFullName.ToString()} {x64} - .Net build {framework}{vbTab}{vbCrLf}" &
$"Internet: Connection test {If(My.Computer.Network.IsAvailable, "succeeded", "failed") _
}, ping google.com {If(pingGoogle, "succeeded", "failed")}{ vbTab}{vbCrLf}" &
$"Form: {If(Not String.IsNullOrEmpty(lblDate.Text), "loaded", "not loaded")}, " &
$"{flpGames.Controls.Count} games currently on form, " &
}, ping google.com {If(pingGoogle, "succeeded", "failed")}{vbTab}{vbCrLf}" &
$"Streamer args {If(tgStreamer.Checked, "enabled", "disabled")}:{txtStreamerArgs.Text}{vbTab}{vbCrLf}" &
$"Player args {If(tgPlayer.Checked, "enabled", "disabled")}:{txtPlayerArgs.Text}{vbTab}{vbCrLf}" &
$"Selected player: {player.ToString()}{vbTab}{vbCrLf}" &
$"Streamer path: {streamerPath.ToString()} [{ _
If(streamerPath.Equals(txtStreamerPath.Text), "on form", "not on form")}] [{ _
Expand Down
2 changes: 1 addition & 1 deletion NHLGames/Objects/GameManager.vb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Namespace Objects
Implements IDisposable
Private _disposedValue As Boolean

Private Shared ReadOnly DictStreamType = New Dictionary(Of String, StreamTypeEnum)() From {
Private Shared ReadOnly DictStreamType As Dictionary(Of String, StreamTypeEnum) = New Dictionary(Of String, StreamTypeEnum)() From {
{"HOME", StreamTypeEnum.Home}, {"AWAY", StreamTypeEnum.Away}, {"NATIONAL", StreamTypeEnum.National},
{"FRENCH", StreamTypeEnum.French},
{"MULTICAM1", StreamTypeEnum.MultiCam1}, {"MULTICAM2", StreamTypeEnum.MultiCam2},
Expand Down
19 changes: 14 additions & 5 deletions NHLGames/Objects/GameWatchArguments.vb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Namespace Objects
Public Property PlayerPath As String = String.Empty
Public Property PlayerType As PlayerTypeEnum = PlayerTypeEnum.None
Public Property StreamerPath As String = String.Empty
Public Property UseCustomStreamerArgs As Boolean = False
Public Property CustomStreamerArgs As String = String.Empty
Public Property UseCustomPlayerArgs As Boolean = False
Public Property CustomPlayerArgs As String = String.Empty
Public Property UseCustomStreamerArgs As Boolean = True
Public Property CustomStreamerArgs As String = " --hls-segment-threads=2 --hls-segment-attempts=10 --hls-segment-timeout=60"
Public Property UseCustomPlayerArgs As Boolean = True
Public Property CustomPlayerArgs As String = " --file-caching=10000 --network-caching=10000 --cache=50000"
Public Property UseOutputArgs As Boolean = False
Public Property PlayerOutputPath As String = String.Empty
Public Property StreamLiveRewind As Integer = 5
Expand All @@ -26,6 +26,15 @@ Namespace Objects
Public Property StreamerType As StreamerTypeEnum = StreamerTypeEnum.None
Public Property StreamLiveReplay As LiveReplayEnum = LiveReplayEnum.StreamStarts

Public Shared ReadOnly StreamerDefaultArgs As Dictionary(Of String, String) = New Dictionary(Of String, String)() From {
{"--hls-segment-threads", "4"}, {"--hls-segment-attempts", "10"}, {"--hls-segment-timeout", "60"}}

Public Shared ReadOnly MpvDefaultArgs As Dictionary(Of String, String) = New Dictionary(Of String, String)() From {
{"--cache", "50000"}}

Public Shared ReadOnly VlcDefaultArgs As Dictionary(Of String, String) = New Dictionary(Of String, String)() From {
{"--file-caching", "10000"}, {"--network-caching", "10000"}}

Public Overrides Function ToString() As String
Return OutputArgs(False)
End Function
Expand Down Expand Up @@ -59,7 +68,7 @@ Namespace Objects
result = PlayerArgs() & ReplayArgs()
End If

result &= ThreadArgs() & ProxyArgs()
result &= ProxyArgs()
If UseCustomStreamerArgs Then result &= CustomStreamerArgs
If Not safeOutput Then result &= NhlCookieArgs()
If Not safeOutput Then result &= UserAgentArgs()
Expand Down
22 changes: 22 additions & 0 deletions NHLGames/Utilities/InitializeForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ Namespace Utilities
New AdDetectionConfigs)
End If

Form.SetStreamerDefaultArgs(Form)
Form.SetPlayerDefaultArgs(Form)

BindAdDetectionConfigsToForm(adDetectionConfigs)

Form.lblNoGames.Location = New Point(((Form.tabGames.Width - Form.lblNoGames.Width) / 2),
Expand Down Expand Up @@ -236,10 +239,27 @@ Namespace Utilities
End If
End Sub

Public Shared Sub SetSelectedPlayer(watchArgs As GameWatchArguments)
If Not String.IsNullOrEmpty(Form.txtMpvPath.Text) Then
watchArgs.PlayerType = PlayerTypeEnum.Mpv
ElseIf Not String.IsNullOrEmpty(Form.txtVLCPath.Text) Then
watchArgs.PlayerType = PlayerTypeEnum.Vlc
ElseIf Not String.IsNullOrEmpty(Form.txtMPCPath.Text) Then
watchArgs.PlayerType = PlayerTypeEnum.Mpc
Else
watchArgs.PlayerType = PlayerTypeEnum.None
End If

ApplicationSettings.SetValue(SettingsEnum.DefaultWatchArgs,
Serialization.SerializeObject(watchArgs))
End Sub

Private Shared Function ValidWatchArgs(watchArgs As GameWatchArguments, playersPath As String(),
streamerPath As String) As Boolean
If watchArgs Is Nothing Then Return True

SetSelectedPlayer(watchArgs)

Dim hasPlayerSet As Boolean = playersPath.Any(Function(x) x = watchArgs.PlayerPath)
If Not watchArgs.StreamerPath.Equals(streamerPath) Then Return True
If Not hasPlayerSet Then
Expand All @@ -264,6 +284,8 @@ Namespace Utilities

Form.tbLiveRewind.Value = If(watchArgs.StreamLiveRewind Mod 5 = 0, watchArgs.StreamLiveRewind / 5, 1)

SetSelectedPlayer(watchArgs)

Form.rbMPV.Checked = watchArgs.PlayerType = PlayerTypeEnum.Mpv AndAlso Form.rbMPV.Enabled
Form.rbVLC.Checked = watchArgs.PlayerType = PlayerTypeEnum.Vlc AndAlso Form.rbVLC.Enabled
Form.rbMPC.Checked = watchArgs.PlayerType = PlayerTypeEnum.Mpc AndAlso Form.rbMPC.Enabled
Expand Down

0 comments on commit 6fd0de3

Please sign in to comment.