How to play System Media Sounds - javascript

I'm developing an Desktop application using ElectronJS.
How can I play System Media sounds?
I know that for C# I can use
// Plays the sound associated with the Asterisk system event.
System.Media.SystemSounds.Asterisk.Play();
How can I do a similar call on ElectronJS?

As far as I am aware, there is no way to play a system sound using an Electron app directly. However, there are workarounds. You can ship with system sounds in your application and playing one depending on the OS your user is running, and shell beeps can be provided by importing shell from Electron and calling shell.beep();.
Another alternative may be detecting what OS is being used and pointing your media player at the relevant system sound file. This can be done with a hidden window that includes an HTML5 media player.

Related

Play game developed with HTML5, CSS and JavaScript without an internet connection

I have developed a game using the technologies mentioned above, however I would like the game not to need a web server to play it, but to run as if it were a desktop application.
I have read that with node js you can create a local web server and with that to run the game, but I don't know how to achieve it.
The idea is that the game has an icon on the desktop and after executing it, it can be played, that is, everything is integrated and the person who has the game does not need to download external programs such as xampp.
Final note: is this possible for smartphones?
Your best bet is ElectronJS, it is a NodeJS library that lets you package browser code as a desktop app. It works for macOS, Linux, and Windows.
Website: https://electronjs.org
Edit: Also once the app is packaged and in your computer you won’t need an internet connection. Final note, it turns it into an actual app so like app for macOS and exe for windows. So they won’t need a web server on their computer to run it.

UWP WebView: Playing audio when the window is minimized without a source

So currently I am developing an application that I'd of hoped to work on Windows, Xbox, etc.
I am trying to developer a wrapper for a javascript library that plays music. This library does not exist in any other form, and only provides the music as encrypted files. It handles playing the audio, pausing, fetching, etc. To change anything you call js methods.
So I am currently using a hidden UWP webview, with custom js/html to play and pause the audio coming from the js library. I was fiddling around with it and noticed if I minimized it, the audio is stopped from the webview. I cannot set a media source for a backgroundtask as I cannot get the actual source of the audio. That is all handled by the js library.
I am hoping to find a way to use UWP, along with this webview "hack". Am I trying to accomplish the impossible?

Implementation workaround for audio issues for Cordova exported Construct 2 games

I am creating a game using Construct 2, but on previewing on Android smartphone, I found Audio playback and delay issue:
This is possibly the curse of Web Audio API in that many browsers require user to touch the screen first or no music will be played. Worse, if another music is to be played, the user must touch the screen once again. This is "by design" of these smartphone browsers. Only Firefox seems to allow music to be played without user initiated touch.
I've seen that this issue has been covered for several times (ex. Website HTML 5 Audio Autoplay and https://stackoverflow.com/a/22331782/144201) and some of the possible suggestions include using other audio javascript libraries entirely such as SoundJS and howler.js.
Has anyone have experience bringing in such audio library that could solve the issue above for Cordova Android export option? Does it work for all Android devices? In fact, can anyone provide me a link for a HTML5 game/page/app, exported with C2 that uses such audio library and play music without requiring user's initial touch on Android so I could check? I just want a confirmation that this is truly possible.
Or is there a more elegant way for Construct 2?
Previewing on browser has the "user must touch screen once" issue because of it is "by design". But if the C2 app is exported via Cordova and uses Crosswalk, the game can play the music without requiring the user to ever touch the screen first.
See https://www.scirra.com/tutorials/809/how-to-export-to-android-with-crosswalk . Although the tutorial is outdated for the current Intel XDK, the instruction is more or less the same. However, the newer C2 versions also create an .xdk file upon Cordova export. In the Intel XDK, you must "Open an Intel XDK project" instead of "Import an existing HTML5 project". See https://software.intel.com/en-us/forums/intel-xdk/topic/607195 for more info.

Is there a command to keep the iPhone camera recording?

Basically, I have an idea for my App, I would like the iPhone camera to keep recording a video even when the user is doing something else (like checking twitter, for example) like a spy cam. I have many coding solutions available
Is there a way I can code this with either HTML5 ,CSS, javascript or xcode?
iOS will not allow you to run the camera constantly in the background. This is because once each app enters the background state, it only has a very short time to wrap-up it's processes and prepare to be suspended (iOS does this to conserve memory).
From the apple developer docs
In iOS, only specific app types are allowed to run in the background:
Apps that play audible content to the user while in the background, such as a music player app
Apps that record audio content while in the background
Apps that keep users informed of their location at all times, such as a navigation app
Apps that support Voice over Internet Protocol (VoIP)
Apps that need to download and process new content regularly
Apps that receive regular updates from external accessories
The only other way to achieve what you want is to jailbreak your device and distribute your app on Cydia (the jailbroken App Store). Jailbreaking will free your device from the restrictions of IOS but will also make your phone a lot more vulnerable to being hacked...

How to play MP3 files into the microphone input jQuery

I am attempting to create it so when a user plays a sound, it plays the sound to the users microphone input. Thus when they're in a Skype Call/Game chat/etc it will be played for all users to hear.
Is there any way to play music to the microphone instead of speakers in Javascript/jQuery? If not, does node-webkit give me any more ability to do this?
Hopefully this is well explained, it is a little challenge.
Thanks for any, and all advise!
This is not possible from the web browser alone. Most systems aren't even capable of this directly.
It is up to the client to decide how to route audio and there is no control of this within the browser, except for what happens within the page itself.
The best you can do is to recommend to your users how to configure their systems. For your Windows users, they will need a virtual audio loopback driver. http://vb-audio.pagesperso-orange.fr/Cable/

Categories