mirror of
https://github.com/Grocel/3D-Stream-Radio.git
synced 2025-03-04 03:03:07 -05:00
Fixed offline Stream URLs with spaces being broken.
- Added extra error code for drive letter paths ("C:/..."). These never worked and shouldn't be used. This will help users to learn how to use relative paths. - Added more information about relative paths to the Stream URL description in the spawner tool. - Removed crash fix in an debug output, as it it has been fixed on engine level. Requires latest game version.
This commit is contained in:
parent
aa7c08c274
commit
6fa5098743
@ -521,9 +521,6 @@ function ENT:FastThink()
|
||||
|
||||
channeltext = string.format("Sound pos, channel: %s", channeltext)
|
||||
|
||||
-- Crashfix: Workaround for: https://github.com/Facepunch/garrysmod-issues/issues/5554
|
||||
channeltext = string.Replace(channeltext, "%", "?")
|
||||
|
||||
debugoverlay.Axis(pos, ang, 5, 0.05, color_white)
|
||||
debugoverlay.EntityTextAtPosition(pos, 1, channeltext, 0.05, color_white)
|
||||
end
|
||||
|
@ -1047,6 +1047,11 @@ function CLASS:PlayStreamInternal(nodownload)
|
||||
self.Metadata = {}
|
||||
|
||||
if not URLonline then
|
||||
if LIBUtil.IsDriveLetterOfflineURL(URL) then
|
||||
self:AcceptStream(nil, LIBError.STREAM_ERROR_BAD_DRIVE_LETTER_PATH)
|
||||
return true
|
||||
end
|
||||
|
||||
return self:_PlayStreamInternal(URL, URLtype)
|
||||
end
|
||||
|
||||
|
@ -143,7 +143,7 @@ function PANEL:Init( )
|
||||
self.URLText:SetUpdateOnType(true)
|
||||
self.URLText:SetHistoryEnabled(false)
|
||||
self.URLText:SetEnterAllowed(true)
|
||||
self.URLText:SetMultiline(false)
|
||||
self.URLText:SetMultiline(true)
|
||||
self.URLText:Dock(FILL)
|
||||
self.URLText:DockMargin( 0, 0, 2, 0 )
|
||||
|
||||
@ -151,7 +151,7 @@ function PANEL:Init( )
|
||||
self.URLText:SetMaxLength(StreamRadioLib.STREAM_URL_MAX_LEN_ONLINE)
|
||||
|
||||
if self.URLText.SetPlaceholderText then
|
||||
-- Some client have some addon conflicts
|
||||
-- Some client have addon conflicts
|
||||
-- This causes them to not have the panel:SetPlaceholderText() function
|
||||
|
||||
self.URLText:SetPlaceholderText("Enter file path or online URL")
|
||||
@ -201,9 +201,25 @@ function PANEL:Init( )
|
||||
return
|
||||
end
|
||||
|
||||
if code == KEY_ENTER then
|
||||
panel:OnEnter(panel:GetText())
|
||||
panel:FocusNext()
|
||||
if code == KEY_ENTER or
|
||||
code == KEY_PAD_ENTER or
|
||||
code == KEY_ESCAPE
|
||||
then
|
||||
timer.Simple(0, function()
|
||||
if not IsValid(self) then
|
||||
return
|
||||
end
|
||||
|
||||
if not IsValid(panel) then
|
||||
return
|
||||
end
|
||||
|
||||
local text = panel:GetText()
|
||||
panel:SetText(text)
|
||||
|
||||
panel:OnEnter(text)
|
||||
panel:FocusNext()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -724,7 +724,6 @@ function PANEL:Init( )
|
||||
self.EditNameLabel:Dock( LEFT )
|
||||
|
||||
self.EditURLText = self.EditURLPanel:Add( "Streamradio_VGUI_URLTextEntry" )
|
||||
self.EditURLText:SetMultiline(true)
|
||||
self.EditURLText:DockMargin( 0, 0, 0, 0 )
|
||||
self.EditURLText:Dock( FILL )
|
||||
|
||||
|
@ -122,15 +122,18 @@ StreamRadioLib.STREAM_URL_INFO = [[
|
||||
You can enter this as a Stream URL:
|
||||
|
||||
Offline content:
|
||||
- A path of a sound file inside your game's 'sound' folder.
|
||||
- A relative path inside your game's 'sound' folder.
|
||||
- The path must lead to a valid sound file.
|
||||
- Mounted content is supported and included.
|
||||
- E.g. music/hl1_song3.mp3
|
||||
- Like: music/hl1_song3.mp3
|
||||
- NOT: sound/music/hl1_song3.mp3
|
||||
- NOT: C:/.../sound/music/hl1_song3.mp3
|
||||
|
||||
Online content:
|
||||
- An URL to an online file or stream.
|
||||
- The URL must lead to valid sound content.
|
||||
- No HTML, no Flash, no Videos, no YouTube
|
||||
- E.g. https://stream.laut.fm/hiphop-forever
|
||||
- Like: https://stream.laut.fm/hiphop-forever
|
||||
]]
|
||||
|
||||
StreamRadioLib.STREAM_URL_INFO = string.gsub(StreamRadioLib.STREAM_URL_INFO, "\r", "")
|
||||
|
@ -665,6 +665,23 @@ LIB.AddStreamErrorCode({
|
||||
helptext = "",
|
||||
})
|
||||
|
||||
LIB.AddStreamErrorCode({
|
||||
id = 1100,
|
||||
name = "STREAM_ERROR_BAD_DRIVE_LETTER_PATH",
|
||||
description = "Drive letter paths are not supported, use relative paths",
|
||||
helptext = [[
|
||||
Do not use drive letter paths. Use relative paths instead.
|
||||
|
||||
A relative path never starts with a drive letter such as "C:/" or "D:/".
|
||||
|
||||
This is a relative path:
|
||||
music/hl1_song3.mp3
|
||||
|
||||
This is NOT a relative path:
|
||||
C:/Program Files (x86)/Steam/steamapps/common/GarrysMod/garrysmod/sound/music/hl1_song3.mp3
|
||||
]],
|
||||
})
|
||||
|
||||
LIB.AddStreamErrorCode({
|
||||
id = 2000,
|
||||
name = "PLAYLIST_ERROR_INVALID_FILE",
|
||||
|
@ -234,7 +234,7 @@ local function loadAddon()
|
||||
-- Sometimes the version is not known, yet.
|
||||
|
||||
if CLIENT then
|
||||
local NEED_VERSION = 230714
|
||||
local NEED_VERSION = 230904
|
||||
|
||||
if VERSION < NEED_VERSION then
|
||||
versionError = string.format("Your GMod-Client (version: %s) is too old!\nPlease update the GMod-Client to version %s or newer!", VERSION, NEED_VERSION)
|
||||
|
@ -351,7 +351,6 @@ function LIB.Setup(toolobj)
|
||||
URLTextEntry:SetConVar( self.Mode .. "_" .. command )
|
||||
URLTextEntry:Dock( FILL )
|
||||
URLTextEntry:DockMargin(0, 5, 0, 0)
|
||||
URLTextEntry:SetMultiline(true)
|
||||
|
||||
bgpanel:SetTall(78)
|
||||
|
||||
|
@ -276,7 +276,12 @@ local function NormalizeOfflineFilename( path )
|
||||
path = string.Replace( path, "../", "" )
|
||||
path = string.Replace( path, "//", "/" )
|
||||
|
||||
path = string.Trim(path)
|
||||
|
||||
path = string.sub(path, 0, StreamRadioLib.STREAM_URL_MAX_LEN_OFFLINE)
|
||||
|
||||
path = string.Trim(path)
|
||||
|
||||
return path
|
||||
end
|
||||
|
||||
@ -299,34 +304,54 @@ end
|
||||
function LIB.NormalizeURL(url)
|
||||
url = LIB.SanitizeUrl(url)
|
||||
|
||||
url = LIBNetURL.normalize(url)
|
||||
url = tostring(url)
|
||||
if not LIB.IsOfflineURL(url) then
|
||||
url = LIBNetURL.normalize(url)
|
||||
url = tostring(url)
|
||||
end
|
||||
|
||||
url = string.Trim(url)
|
||||
|
||||
return url
|
||||
end
|
||||
|
||||
function LIB.IsOfflineURL( url )
|
||||
url = string.Trim( url or "" )
|
||||
local protocol = string.Trim( string.match( url, ( "([ -~]+):[//\\][//\\]" ) ) or "" )
|
||||
local protocol = string.Trim( string.match( url, ( "^([ -~]+):[//\\][//\\]" ) ) or "" )
|
||||
|
||||
if ( protocol == "" ) then
|
||||
if protocol == "" then
|
||||
return true
|
||||
end
|
||||
|
||||
if ( protocol == "file" ) then
|
||||
if protocol == "file" then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function LIB.IsDriveLetterOfflineURL( url )
|
||||
if not LIB.IsOfflineURL(url) then
|
||||
return false
|
||||
end
|
||||
|
||||
url = string.Trim( url or "" )
|
||||
|
||||
local driveLetter = string.Trim( string.match( url, ( "([a-zA-Z]+):[//\\]" ) ) or "" )
|
||||
|
||||
if driveLetter == "" then
|
||||
return false
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
function LIB.ConvertURL( url )
|
||||
url = LIB.SanitizeUrl(url)
|
||||
|
||||
if LIB.IsOfflineURL( url ) then
|
||||
local fileurl = LIB.SanitizeUrl( string.match( url, ( ":[//\\][//\\]([ -~]+)" ) ) or "" )
|
||||
local fileurl = LIB.SanitizeUrl( string.match( url, ( ":[//\\][//\\]([ -~]+)$" ) ) or "" )
|
||||
|
||||
if ( fileurl ~= "" ) then
|
||||
if fileurl ~= "" then
|
||||
url = fileurl
|
||||
end
|
||||
|
||||
|
@ -129,7 +129,7 @@ function TOOL:BuildToolPanel(CPanel)
|
||||
self:AddURLTextEntry( CPanel, "streamurl", false )
|
||||
|
||||
local _, StreamUrlInfoText = self:AddReadOnlyTextBox( CPanel, "streamurlinfo" )
|
||||
StreamUrlInfoText:SetTall(225)
|
||||
StreamUrlInfoText:SetTall(245)
|
||||
|
||||
CPanel:AddPanel(StreamRadioLib.Menu.GetSpacerLine())
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
429
|
||||
1694360202
|
||||
430
|
||||
1694369050
|
||||
|
Loading…
Reference in New Issue
Block a user