Stop streaming audio with myStreamin.stop ();

0 favourites
  • 5 posts
From the Asset Store
Warfare Audio Kit
$4.40 USD
60% off
126 audio files divided in: music, radio voices, SFX
  • I want to create an online radio app.

    I managed to play an external audio, but I can't stop it!

    apparently the mySteaming variable is destroyed after the script is finished. I'm obviously doing something wrong, can someone help me?

    Link Cp3

    https://https://drive.google.com/file/d/13IOtenRjFZtM3jW4Wnnls5p_vIeZFoQq/view?usp=sharing

    Tagged:

  • I believe you're running into another version of the same problem I describe here:

    construct.net/en/forum/construct-3/scripting-51/declaring-objects-script-160208

    To put it simply, each script block has its own namespace, so the 'MyStreaming' variable isn't exactly destroyed - it simply cannot be accessed outside the block where it was created.

    The solution is to declare your stream in a way that's globally accessible. I don't know much javascript, so the way I've started to do it is by creating things by the window object, which is probably a dumb way to go about it, but works for me.

    What you'd do in your example is instead of declaring your stream using 'var myStreaming =', declare it like 'window.myStreaming =' - the window object will be accessible from your other block, and thus 'window.myStreaming.stop()' should hopefully work. Good luck!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I believe you're running into another version of the same problem I describe here:

    https://www.construct.net/en/forum/construct-3/scripting-51/declaring-objects-script-160208

    To put it simply, each script block has its own namespace, so the 'MyStreaming' variable isn't exactly destroyed - it simply cannot be accessed outside the block where it was created.

    The solution is to declare your stream in a way that's globally accessible. I don't know much javascript, so the way I've started to do it is by creating things by the window object, which is probably a dumb way to go about it, but works for me.

    What you'd do in your example is instead of declaring your stream using 'var myStreaming =', declare it like 'window.myStreaming =' - the window object will be accessible from your other block, and thus 'window.myStreaming.stop()' should hopefully work. Good luck!

    Thanks, it is true that windows works to keep variables from one block to another, but there is something that my code is missing, an id to identify the audio that has been played, since I can not even stop the audio within the same block.

    I have to investigate how to identify that audio, although I do not know javascript I will not give up!

  • In the end I did it using remote URL! Before I had already tried without success, but now when removing the codec in the Type parameter it worked magically!

  • I believe you're running into another version of the same problem I describe here:

    https://www.construct.net/en/forum/construct-3/scripting-51/declaring-objects-script-160208

    To put it simply, each script block has its own namespace, so the 'MyStreaming' variable isn't exactly destroyed - it simply cannot be accessed outside the block where it was created.

    The solution is to declare your stream in a way that's globally accessible. I don't know much javascript, so the way I've started to do it is by creating things by the window object, which is probably a dumb way to go about it, but works for me.

    What you'd do in your example is instead of declaring your stream using 'var myStreaming =', declare it like 'window.myStreaming =' - the window object will be accessible from your other block, and thus 'window.myStreaming.stop()' should hopefully work. Good luck!

    This works!!! the problem was the code window.MyStream.stop() for some reason does not work, but if it works window.MyStream.pause() without any problem! now I don't know which of the 2 ways to use :D!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)