Coder Social home page Coder Social logo

grocel / 3d-stream-radio Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 4.0 7.46 MB

It is an spawnable scripted entity for Garry's Mod that allows you to play online streams and local files as 3D world sound.

Home Page: https://steamcommunity.com/sharedfiles/filedetails/?id=246756300

Lua 99.71% Shell 0.02% Batchfile 0.27%
3d-stream-radio addon audio-streaming bass bass-library garrys-mod garrysmod garrysmod-addon garrysmod-tool garrysmodlua gmod gmod-lua gmodaddon gmodlua music radio sound stream streaming wiremod

3d-stream-radio's People

Contributors

grocel avatar nepeat avatar somefoolouthere avatar wrefgtzweve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

3d-stream-radio's Issues

Other users cannot drag volume slider in C menu

The owner of a stream radio can change the volume with the C menu while other people cannot change it.
Other players should be able to change the volume for the stream radio in the C menu because some models do not have screens attached to them, and the owner of the radio can disable input which doesn't allow people to change the volume.
Some people may not like the music that is being played, and cannot lower the volume or stop the song from playing and they want to hear other radios, which the above makes it so they are unable to change the volume.

I suggest making it so people can change the volume via the C menu because the stream radio already has a menu for it.
(Image below shows a stream radio without a screen and the C menu for that radio)

image

Add support for PermaProps

PermaProps uses non-standard methods for storing and restorting entities on a map between sessions. At the moment this addon only supports the official duplication API for storing entity data so it works with every duplication/persisting addon that uses the duplication API. PermaProps is, because of its non-standard implementation, not supported yet.

Fortunately PermaProps has an API for custom entity handling:
https://github.com/MalboroDEV/PermaProps/blob/master/lua/permaprops/sv_specialfcn.lua

IsConnectedWirelink does not check for "virtual" wirelinks

Issue:

When connecting to a Stream Radio entity with a "virtual" wirelink1, the IsConnectedWirelink function does not recognize that wirelink, because it only checks if the "physical" input has been wired to something.

See IsConnectedWirelink function:
https://github.com/Grocel/3D-Stream-Radio/blame/6fa509874358b5bd58c6ba87fb1e6ee6e55866a1/lua/entities/base_streamradio.lua#L812-L814

Result:

When trying to set / trigger an input change of (for example) the Stream URL (does apply to any other input as well), it will not actually change the internal value due to the hard-coded check if that specific input has been wired.

See here:
https://github.com/Grocel/3D-Stream-Radio/blame/6fa509874358b5bd58c6ba87fb1e6ee6e55866a1/lua/entities/sent_streamradio/init.lua#L983C3-L985


This also leads to the following effects:

1. Inconsistency: the majority of other wireable entities do not ignore "virtual" wirelinks and their input changes, even if the corresponding "phyiscal" wire input has not been actually wired.

2. Confusion: it is not visible or known to someone working with the entity, that inputs will be "scrapped" if the corresponding wire input is not "physically" hooked up to something.

Footnotes

  1. A "virtual" wirelink is a wirelink that is created / assigned purely from within a script execution background (e.g. Expression 2, Starfall, ...)
    For example (Expression 2): Wirelink = entity():isWeldedTo():wirelink() - returns the wirelink of that entity the chip is welded to, without actually ever wiring the input of that entity โ†ฉ

Translations system

Would love to help with Russian translation for this omega radio addon :p

Add on-screen button to toggle track loop and playlist looping.

Suggested by Peekofwar on 2023-05-18:

Something that could be useful for VR users would be on-screen buttons to toggle track loop and playlist looping. This could even be one button with more than one mode using icons to indicate which mode it's in.

[Suggestion] Stream Audio Files from Server Directory

The idea is to create a special directory somewhere in the server/game directory that Stream Radio is allowed to stream audio from.

Usually I use Discord file links to stream some of the files I play in-game, however Discord has since changed their file link system to remove permanent links. I could theoretically make an unlisted addon that puts music files in-game, but something that would be nice is if I could just upload audio files to a special directory on the GMod server that Stream Radio is allowed to stream from. Only the server host would be allowed to use this feature since it requires access to the file system.

It's hard to find file services these days that allow you to use direct file links.

Of course, this raises the question of how do we denote that a URL is for a server file...? Maybe it could just start with SERVER:// or something like that...

Peekofwar: Wiremod input for playlist URLs.

@Peekofwar on Workshop:

Would be cool if there was a Wire playlist URL array input to allow us to input an entire playlist into a radio entity through Wiremod.

In the most recent updates I changed the structure and handing of playlist data in the radio entity to separate it from the GUI elements, so non-display radios can use and store and playlist data too. This is needed to implement the playlist input.

There are some issues with this I would have to solve first:

  1. All online URLs inputted via the playlist input must be filtered on disabled custom URLs to prevent abuse/bypass. I am not sure how to implement this in a way the user would understand this blocking behavior yet. This might need issue #9 to be finished first.
  2. Each playlist entry also needs a name. Could be solved with Wire input #1, Wire input #2, ..., Wire input #N, but this looks kinda lazy and maybe confusing to the user too.

stack overflow

[3D Stream Radio] stack overflow
  1. istable - [C]:-1
   2. __newindex - lua/streamradio_core/classes/base_listener.lua:442
    3. callback - lua/streamradio_core/classes/stream.lua:182
     4. __newindex - lua/streamradio_core/classes/base_listener.lua:459
      5. callback - lua/streamradio_core/classes/stream.lua:182
       6. __newindex - lua/streamradio_core/classes/base_listener.lua:459
        7. callback - lua/streamradio_core/classes/stream.lua:182
         8. __newindex - lua/streamradio_core/classes/base_listener.lua:459
          9. callback - lua/streamradio_core/classes/stream.lua:182
           10. __newindex - lua/streamradio_core/classes/base_listener.lua:459
            11. callback - lua/streamradio_core/classes/stream.lua:182
             12. __newindex - lua/streamradio_core/classes/base_listener.lua:459
              13. callback - lua/streamradio_core/classes/stream.lua:182
               14. __newindex - lua/streamradio_core/classes/base_listener.lua:459
                15. callback - lua/streamradio_core/classes/stream.lua:182
                 16. __newindex - lua/streamradio_core/classes/base_listener.lua:459

Fix playtime synchronization

It has been reported multiple times that sometimes the radio is stuck at the beginning of a song, so it loops the first 1.5 seconds of the track.

As far as I know it is an networking issue. I was not able to reliably reproduce it yet.

Clientside lua error

Im not sure how to replicate this issue unfortunately. However i have the stack trace.
Players are getting this error pretty rarely but i thought, might as well report it.

addons/3d_stream_radio/lua/streamradio_core/tool.lua:15: attempt to call method 'GetToolObject' (a nil value)
  1. GetTool - addons/3d_stream_radio/lua/streamradio_core/tool.lua:15
   2. func - addons/3d_stream_radio/lua/streamradio_core/tool.lua:347
    3. unknown - addons/3d_stream_radio/lua/streamradio_core/timer.lua:36

Peekofwar: About the audio cache.

@Peekofwar on Workshop:

Heck, I just discovered that there's an audio cache... I have some cached DAT files from 2018, and interestingly, Audacity allows me to just drag the DAT files right into it to view them.

https://github.com/Grocel/3D-Stream-Radio/blob/master/lua/streamradio_core/cache.lua#L17-L21

Yes, indeed. Files are downloaded in the background via HTTP() to make the loadup faster the next time the radio plays an online file. It reduces traffic and is a good Anti-DDoS/Anti-Spam too.

It only works with files with a length (e.g. not radio streams). Only files less then 1.5h long are cached. The cache is capped at 16 GB total size and 1024 files. Each file is limited to 256 MB. Small files (HTTP requests) are even cached in memory (max 16x16 MB) as an additional de-duplication of requests. Small files (<64 KB) that could just be an HTML error page or something are never cached. Caching is only attempted when the radio does not error on playback, which means only valid sound content ends up there.

You can clear the file cache any time by deleting the cache folder or by using "cl_streamradio_cacheclear" ingame. The dat files can be any sound file and are saved as dat because of engine restrictions.

Server side error on server start that breaks addon (workshop version)

An error prints to console on server start since the latest major workshop update.

[3D Stream Radio] lua/weapons/gmod_tool/stools/streamradio.lua:16: attempt to call field 'GetDefaultModel' (a nil value)
  1. unknown - lua/weapons/gmod_tool/stools/streamradio.lua:16
   2. include - [C]:-1
    3. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/stool.lua:154
     4. include - [C]:-1
      5. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/shared.lua:372
       6. include - [C]:-1
        7. unknown - gamemodes/sandbox/entities/weapons/gmod_tool/init.lua:10

Framedrop on radio spawn

I noticed that the radio causes a frame drop of about between 200 to 500 ms on my computer when it is spawned.

It his is caused by the GUI system initializing its caches and elements. I will see if I can fix that by using Lua coroutines, but I can not do any promises.

Clientside load error preventing usage.

[ERROR] addons/streamradio/lua/autorun/streamradio_loader.lua:529: attempt to concatenate field 'ErrorString' (a nil value)
  1. func - addons/streamradio/lua/autorun/streamradio_loader.lua:529
   2. unknown - lua/includes/extensions/net.lua:32

This error appears for any player joining the server, prevents anyone from spawning radios.

Add stream url whitelisting based on installed playlists

When the convar sv_streamradio_allow_customurls set to 0 the radio does not accept any URL that has been manually inputted (wiremod, toolgun, dupe) into the radio. This is for security reasons.

Even when the URL is actually existing inside a playlist it would not play if it was not picked from the playlist view in the GUI. The goal of this change is that the URL no longer blocked in this case. So the playlist files are the server's whitelist so to speak.

It is however unclear if I will be able to implement this in the near feature.

UI Bugged First Time Opening Audio File

I ran into a perculiar bug today when I went to touch Stream Radio... When I first open an audio file, the UI loads in in a buggy state. At first nothing appears wrong when you look at the interface and tooltips and button rollover effects work normally and display correct tooltips, however when you attempt to actually interract with them, it seems as though the buttons are not where they should be.

At first load of the stream player UI, the button order is as follows: Pause, Stop, Decrease Volume, Increase Volume, Timeline, Back.
image
However, if you exit the player and then open the file again, the interface loads with this layout: Pause, Stop, Previous Track, Next Track, Decrease Volume, Increase Volume, Loop Mode,, Timeline, Back. This is the order in which interactions trigger even if the previous button order is displayed.
image

Stream.Radio.Ui.Bug-1.mp4

For additional context: This bug was encountered whilst playing on a dedicated server that had just been restarted (also meaning all addons were freshly updated).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.