The URL can be set by either:
1. Setting the `baseUrl` property in `config/default.json`,
`config/local.json`, or `config/${NODE_ENV}.json` file.
2. Setting the `PEERCALLS_BASE_URL` environment variable.
For example:
```
$ PEERCALLS_BASE_URL=/test1/test2 npm start
> peer-calls@2.0.3 start /peer-calls
> node src/index.js
peercalls WebSocket URL: /test1/test2/ws +0ms
peercalls Listening on: 3000 +76ms
```
In this case, opening `http://localhost:3000/test1/test2` would open the
homepage.
Fix #42
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import Promise from 'bluebird'
|
|
import _debug from 'debug'
|
|
|
|
const debug = _debug('peercalls')
|
|
|
|
export function getUserMedia (constraints) {
|
|
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
return navigator.mediaDevices.getUserMedia(constraints)
|
|
}
|
|
|
|
return new Promise((resolve, reject) => {
|
|
const getMedia = navigator.getUserMedia || navigator.webkitGetUserMedia
|
|
if (!getMedia) reject(new Error('Browser unsupported'))
|
|
getMedia.call(navigator, constraints, resolve, reject)
|
|
})
|
|
}
|
|
|
|
export const createObjectURL = object => window.URL.createObjectURL(object)
|
|
export const revokeObjectURL = url => window.URL.revokeObjectURL(url)
|
|
|
|
export const navigator = window.navigator
|
|
|
|
export function play () {
|
|
let videos = window.document.querySelectorAll('video')
|
|
Array.prototype.forEach.call(videos, (video, index) => {
|
|
debug('playing video: %s', index)
|
|
try {
|
|
video.play()
|
|
} catch (e) {
|
|
debug('error playing video: %s', e.name)
|
|
}
|
|
})
|
|
}
|
|
|
|
export const valueOf = id => {
|
|
const el = window.document.getElementById(id)
|
|
return el && el.value
|
|
}
|
|
|
|
export const baseUrl = valueOf('baseUrl')
|
|
export const callId = valueOf('callId')
|
|
export const iceServers = JSON.parse(valueOf('iceServers'))
|
|
|
|
export const MediaStream = window.MediaStream
|