Player API
The js-dos player provides a single entry point: the Dos function. It takes two arguments:
the element where the player window should be created
an options object to configure the player
It returns DosProps, which you can use to control the created player.
Options
option | description | type | default |
|---|---|---|---|
url | URL to a js-dos bundle | URL | |
dosboxConf | If you omit | string | |
jsdosConf | Additional js-dos configuration ( | object |
|
initFs | Additional files to initialize the file system. Read more. |
| |
background | Background image of the player window. | URL | |
pathPrefix | Path prefix for emulators deployment files. | string |
|
pathSuffix | Suffix appended to emulator deployment file paths. | string |
|
theme | Color theme of the player. | light, dark, cupcake, bumblebee, emerald, corporate, synthwave, retro, cyberpunk, valentine, halloween, garden, forest, aqua, lofi, pastel, fantasy, wireframe, black, luxury, dracula, cmyk, autumn, business, acid, lemonade, night, coffee, winter | light or dark by system preference |
lang | Player language. | en, ru | auto |
backend | Default backend. | dosbox, dosboxX | dosbox |
backendLocked | Prevents changing the backend from the UI. | boolean | false |
backendHardware | Function that returns a hardware backend endpoint for the selected backend. |
| |
workerThread | Run the backend in a Worker. | boolean | true |
offscreenCanvas | Use | boolean | false |
mouseCapture | Lock the mouse in the player window. | boolean | false |
fullScreen | Automatically enter fullscreen mode. | boolean | false |
onEvent | Listener for js-dos events. | function | |
autoStart | Automatically start emulation. | boolean | false |
fastForwardOnBoot | Fast-forward boot for the specified number of seconds when a sockdrive bundle is used. | number | 0 |
countDownStart | Set countdown before auto start, in seconds. | number | 0 |
autoSave | Automatically save progress on certain actions, such as exiting fullscreen. | boolean | false |
kiosk | Enable kiosk mode; in kiosk mode the player UI is hidden. | boolean | false |
imageRendering | Image rendering mode. | pixelated, smooth | pixelated |
renderBackend | Renderer for the DOS screen. | webgl, canvas | webgl |
renderAspect | Aspect ratio of the output window. | AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit | AsIs |
scaleControls | Scale of controls. | number | 0.2 |
mouseSensitivity | Mouse sensitivity. | number | 0.5 |
noCursor | Hide the system cursor. | boolean | false |
volume | Sound volume. | number [0..1] | 1.0 |
softKeyboardLayout | Initial virtual keyboard layout. Read more. |
| built-in qwerty layout |
softKeyboardSymbols | Initial virtual keyboard symbols. |
| built-in symbols |
softFullscreen | If set to | boolean | false |
thinSidebar | Start the player with the thin sidebar. | boolean | false |
sockdrivePreload | Controls sockdrive preloading. | none, all, default | default |
startIpxServer | Start an IPX server for multiplayer networking. | boolean | false |
connectIpxAddress | Connect to an IPX peer ID or registered alias. | string | |
fsChanges | Options to configure save/load. | object |
|
net | WebRTC networking configuration. |
| js-dos defaults |
sharedNet | Reuse an existing WebRTC networking instance between players. |
|
DosProps
DosProps are properties that you can use to control the player after creation. Use them like this:
property | description | arguments |
|---|---|---|
getVersion | version of js-dos + emulators | |
getLocalChanges | return current FS changes read more | key |
setTheme | switch player theme | theme name |
setLang | change language | en, ru |
setBackend | change backend | dosbox, dosboxX |
setBackendLocked | lock or unlock backend selection | bool |
setWorkerThread | select execution mode | bool |
setOffscreenCanvas | enable or disable | bool |
setMouseCapture | enable or disable mouse capture | bool |
setBackground | change background image | URL or null |
setFullScreen | change fullscreen mode | bool |
setAutoStart | change auto start | bool |
setCountDownStart | set countdown to auto start in seconds | number |
setAutoSave | change auto save mode | bool |
setKiosk | change kiosk mode | bool |
setImageRendering | change image rendering | pixelated, smooth |
setRenderBackend | change render backend (available only before emulation start) | webgl, canvas |
setRenderAspect | change render aspect | AsIs, 1/1, 5/4, 4/3, 16/10, 16/9, Fit |
setNoCloud | disable/enable cloud feature | bool |
setScaleControls | set scale of controls | number |
setMouseSensitivity | set mouse sensitivity | number |
setPaused | pause/resume emulation | bool |
setNoCursor | show/hide system cursor | bool |
setVolume | set sound volume | number [0..1] |
setSoftKeyboardLayout | set virtual keyboard layout |
|
setSoftKeyboardSymbols | set virtual keyboard symbols | map[] |
setSoftFullscreen | set soft fullscreen | bool |
setThinSidebar | switch between normal and thin sidebar | bool |
save | trigger saving FS changes, returns | - |
stop | kill the emulation (use to stop player) | - |
setNoCloud(true) hides cloud-related UI. It does not disable local saves; use fsChanges.local: false for that.
Events
You can listen to js-dos events by providing a listener in the Dos function:
order | event | description | args |
|---|---|---|---|
0 | emu-ready | when emulators are fully loaded and ready to run the program | |
1 | bnd-play | when play button is clicked | |
2 | ci-ready | when backend is started and CommandInterface is available | |
fullscreen-change | when fullscreen state of player changed | boolean |
Stop/Restart player
To stop player and free all used resources, please call
props.stop(), after this player is totally disposed.To restart player dispose current player and start new one.
Typescript
js-dos provides Typescript type declarations. Just put it somewhere in your codebase, and declare Dos function: