wmsgva's Forum Posts

  • Animate

    Yes, you could store many stream URLs in an XML file and then call the StartPlaying action to play them. For example:

    Global Text MyVariable = ""

    Ajax.Request yourfile.xml (tag "myfile")

    Ajax.On "myfile" completed

    XML.Load XML document from string AJAX.LastData

    System.Set MyVariable to XML.StringValue("/Gamedata/Streams/Text/Content/text()"")

    Audiostream.StartPlaying(MyVariable)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • SOLVED!

    Just created a plugin called Audiostream which allows to stream and stop playing online streams.

  • Just completed my first plugin for Construct 2.

    The Audiostream plugin allows you to play online audio streams within the platform.

    1. Actions:

    Audiostream.StartPlaying (stream URL): Starts playing the specified online audio stream

    Audiostream.Stop Playing: Stops the stream currently playing

    2. Conditions:

    Has stream: Has a stream defined or not

    Is playing: Stream is currently playing or not

    3. Expressions:

    Stream: Returns URL of stream currently defined (String)

    4. Known issues:

    • The plugin currently works in development mode and when a game is exported to HTML 5. It doesn't however work with games exported via NW.js

    (if any specialist plugin creators have an idea why, please let me know)

    • Works natively under Chrome, but requires server side definition of aac mime type for other browsers

    5. To install:

    Download from:

    Then unzip to \Program Files\Construct 2\exporters\html5\plugins

    6. Update history:

    Version 1.1 : Improved memory management

    Version 1.2 : Prevent plugin crash if Audiostream.Stop is called before any stream has been played

  • Thanks Naji

  • I have been playing around with this issue since I uploaded my game prototype to the website (as it's intended to be played from desktop computers, was previously testing exports with NW.js only).

    There seem to be two main issues to me, which are partly Construct 2 design problems:

    1) The loadingprogress system variable is designed to contain values meaning different things, which is not ideal (would be better to have two separate variables, one showing the progress for game updates and another for layout load)

    2) The Browser.On Update Ready signal only triggers when an update upload is complete (game running from cache and downloading new version). This is an issue when a person starts the game for the first time (game not running from cache). The Browser.Is Downloading Update will be True (allowing me to then use a timer to show update progression using loadingprogress), but the On Update Ready signal never fires to allow the game to move onto the first layout (player just sees "Loading game 100% complete")

    So, to recap, there are three situations:

    1) Player starting game for the first time in a browser

    2) Player running the game again (uses cache) and an update is available

    3) Player running the game again and no update available

    Situations 2 & 3 are managed as follows and work fine:

    ...

    Browser.Is Downloading Update -> System Set FlagGameUpdate = True

    Else Goto FirstLayout

    System Every 2 seconds

    System FlagGameUpdate = True -> TxtIntroUpdate Set Text to "Loading game update... " & round(loadingprogress*100) " %"

    ->Browser.On Update Ready -> System Set FlagGameUpdate to FALSE

    Browser.Reload

    Problem is situation 1, as with the On Update Ready not being triggered, I haven't found how to automatically reload the page. Any ideas?

  • A great idea Naji. Although one can copy previous templates, it makes it easier to keep things tidy when starting a new plugin.

  • I think this is basically a question for Ashley: Is there any way in which the light object could provide soft edges when using a radius of zero to control the shade's range?

  • Well, LittleStain, I agree regarding the example I used above (probably not the best choice, as these are static), but there are other cases in which the light intensity needs to vary. I suppose I could use a set of static frames and move between the frames as intensity increases/diminishes, but I wanted to see if using the "dynamic" light/shadow objects was possible. Otherwise, I will probable revert to such a solution.

  • I am currently working on a serious game which manages day/night transitions. When the player is in some of the rooms, he/she can turn lights on or off.

    In order to create light sources, I have some Shadow Light objects on an opaque black layer above the background project light onto the lamps which then reflect the light (instead of shadows). This trick works by having the Shadow Lights using the "Destination Out" blend mode (their "shadow" therefore reveals the layer below).

    See below:

    dropbox.com/s/z82jbgnhfinos ... g.png?dl=0

    My issue is the following when using the light sources: Either you set their radius to zero and can then determine the range of diffusion of the light (see left lamp above), but the edges of the light aren't smooth or you set the light's radius and have a nice natural looking light (see right lamp above), but the light extends off the screen.

    I know this seems to be a limitation of the light/shadow caster plugins in C2, but has anyone an idea how to prevent the shade from extending off the screen edges without having to have hard looking shade edges?

  • Perhaps an issue with your lights. If the Radius value you specified for your Shadow Light object is not zero, then light height is ignored.

  • Hi Coin-Coin, I'm afraid not. I haven't had time to look much further into this. The only solution I can see at the moment would be to create a new Audio plugin which would both allow people to create a stream with the code I used with "Execute javascript" and retain the handle to the execute the audio.pause. If you hear of anyone who wants to write such a plugin, let me know.

  • Hi Rex, I like the idea of your plugin to ensure a smooth sound transition.

    Another issue I've been trying to solve is to allow C2 to play sound streams instead of just sound files. I found a way of doing so by using an external

    javascript call with the browser object:

    Browser.Execute Javascript "var audio = new Audio('http://onefm.ice.infomaniak.ch:80/onefm-high.aac');audio.play();"

    This works fine and allows me to play a local radio station streamed from their website. The only issue I have is I can't stop the sound,

    as I don't think there's any way in which I can retrieve the audio pointer that is assigned above to the issue the following javascript command

    in the same way:

    Browser.Execute Javascript "audio.pause();audio.currentTime = 0;"

    Because of this, I was thinking of writing a new plugin based on the standard C2 audio one. Do you think you could integrate a "playstream"

    command to your audio plugin? This would really help me tremendously (avoiding having to create a plugin just for this issue) and I'm sure

    would prove to be a valuable addition for the C2 community.

    Let me know what you think. Cheers.

  • The browser close detection Nimos100 is asking for could be provided by extending the triggers for the Browser object with the "BeforeUnload" event. It works

    using javascript with window.onbeforeunload ...

    Another suggestion for the "Audio" Object:

    • Add the ability to play a sound stream, not just a sound file.

    I have currently managed to do this using the Browser.Execute javascript with the following parameter:

    "var audio = document.createElement('audio');audio.src='http://onefm.ice.infomaniak.ch:80/onefm-high.aac';audio.play();"

    (Replace the information under audio.src with the address of your stream and it should work fine)

    The only issue is I haven't found how to stop the audio from playing (I can't find a way to get the instance stored in the audio variable back to Construct to then call audio.pause() in the same way. If anyone has an idea, it would be great

  • Found the source of the problem. I had made the mistake of setting the compression for some of the sprites to JPEG.

    Those with transparent areas don't support this and must use png8 if they need to be compressed.

  • Thanks Zenox.

    This seems to point to a graphic card driver issue as several of us suspected. I recently updated to the latest drivers from NVidia.

    Are you also using an NVidia card and if so, with which driver version?