Skip to content

A countdown timer for display in VR / XR using Microsoft's Virtual Reality extensions

License

Notifications You must be signed in to change notification settings

yitzikc/mre-alarm-timer

Repository files navigation

Alarm Timer for the Mixed Reality Extension SDK

This is a countdown timer which you can embed into an AltspaceVR virtual world. It's written using the Mixed Reality Extension SDK.

Prerequisites

Node.js 14 with Typescript support.

How to Build and Run

  • Clone the repository and
  • Change to the top-level directory of the repository.
  • If you want to access the MRE by a hostname other than localhost, create a .env file to define your desired hostname (see .env.example). Note, that MRE SDK can detect correctly the settings used by some popular hosting environments, notably Azure.
  • npm install This will install all dependent packages. (and will do very little if there are no changes).
  • npm run build This should not report any errors.
  • npm start This should print "INF: Multi-peer Adapter listening on..."

In AltspaceVR:

  • Go to your personal home
  • Make sure you are signed in properly, not a guest
  • Activate the Space Editor (only available if you indicate you want to participate in the Early Access Program in your AltspaceVR settings)
  • Click Basics group
  • Click on SDKApp
  • For the URL field, enter ws://localhost:3901. If you've configured a different hostname, use that instead.
  • Click Confirm
  • If the app doesn't seem to load, click on the gear icon next the MRE object in to the present objects list, and make sure "Is Playing" is checked.
  • After the app has been placed, you will see the MRE Anchor (the white box with red/green/blue spikes on it), rendering on top of the MRE. You can use the anchor to move the MRE around. To hide the anchor, uncheck "Edit Mode".

Behavior

You should now see a counter counting down from the count value you've set towards 0. Clicking it the first time will stop any alarm that's playing, or if the counter is still counting, it will be paused. Clicking a second time will either increment the count time by the increment value, if it is non-zero, or if it is 0, set the counter to the initial count value.

Configuration

Many aspects of the timer's operation can be customized. This is done using query parameters in the URL.

  • c - Set the initial count in seconds. The default value is 60.
  • i - Set the increment in seconds. The default value is 60. If the value is set to 0 the behavior changes. A click would instead set the count back to the initial count value.
  • v - Set the volume of the alarm. A value between 0 and 100. The default is 50.
  • l - Loop the sound until paused. The allowed values are y or n. The default is n.
  • p - Pause-only mode. While the sound is playing, clicking the MRE will alternately pause and resume the playback. The allowed values are y or n. The default is n.
  • am - Ambient sound. If enabled, set the sound to play with uniform volume within a large distance from the source. The allowed values are y or n. The default is n.
  • mo - Moderator only. If set to y, then only moderators can view and manipulate the counter.
  • as - Alarm sound. An http or https URL pointing to of the audio file to play as alarm. Alternatively, the relative path of the audio file in the public directory from which media are served. It should point to a .wav or .ogg file. Note, that if a full URL is used, it will likely require percent-quoting of some characters.

Example: Run the MRE locally with an initial count of 30 seconds, incremented by 15 seconds whenever the counter is clicked. A custom audio file myalarm.wav is specified

ws://localhost:3901/?c=30&i=15&as=myalarm.wav

Example: Run the MRE on a server with SSL. Set the counter to 60 seconds whenever clicked. Only moderators can view the timer.

wss://my.ssl.server.io/?c=60&i=0&mo=y

Hosting in the Cloud

This MRE is built using Node.JS 14. Check out DEPLOYING.md in the SDK repo for more suggestions.

In particular, deployment to a Heroku Dyno is well supported. To deploy there, set-up your project to use Node-JS and set the environment variable BASE_URL to be your Heroku https URL. Use the corresponding wss:// URL to access the MRE in the world. Everything else should be handled automatically by Heroku.

Using custom audio files

To use your own audio files, you need to get them into the public directory in .ogg or .wav files. Then you can use the as parameter to specify your own audio file, A way to accomplish this in Heroku (or other environments that use git push to deploy) would be to clone this repository, then commit your audio files to your local Git repository and push that to your hosting environment.

About

A countdown timer for display in VR / XR using Microsoft's Virtual Reality extensions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •