Photon Voice API
Classes
- AudioPlayer
- AudioSource
- CanvasRenderer
- Decoder
- Encoder
- LBTransport
- LocalVoice
- LocalVoiceAudio
- RemoteVoiceOptions
- VideoFrame
- VoiceClient
- VoiceInfo
Members
(static, readonly) Codec :number
Codecs.
Type:
- number
Properties:
Name | Type | Description |
---|---|---|
NONE |
number | |
AUDIO_OPUS |
number | Audio Opus |
VIDEO_VP8 |
number | Video VP8 |
VIDEO_VP9 |
number | Video VP9 |
VIDEO_AV1 |
number | Video AV1 |
VIDEO_H264 |
number | Video H.264 |
VIDEO_H265 |
number | Video H.265 |
Methods
createAudioDecoder(output) → {Photon.Voice.Decoder}
Creates audio decoder.
Parameters:
Name | Type | Description |
---|---|---|
output |
Photon.Voice.AudioDecoderCallback | Audio frame output callback. |
Returns:
Reference to the created audio decoder.
- Type
- Photon.Voice.Decoder
createAudioPLayer(voiceInfo, jitterDelayMs) → {Photon.Voice.AudioPlayer}
Creates audio player.
Parameters:
Name | Type | Description |
---|---|---|
voiceInfo |
Photon.Voice.VoiceInfo | Stream parameters. |
jitterDelayMs |
number | Jitter buffer size in ms. |
Returns:
Reference to the created audio player.
createCameraEncoder(device, info, videoElement) → {Photon.Voice.Encoder}
Creates a camera video source connected to a video encoder.
Parameters:
Name | Type | Description |
---|---|---|
device |
string | The name of the camera device to capture. Empty string for the default camera. |
info |
Photon.Voice.VoiceInfo | Stream parameters. |
videoElement |
HTMLVideoElement | Video element that drives the source and serves as a preview. |
Returns:
Reference to the created video encoder.
- Type
- Photon.Voice.Encoder
createCanvasRenderer(videoElement) → {Photon.Voice.CanvasRenderer}
Creates video renderer.
Parameters:
Name | Type | Description |
---|---|---|
videoElement |
HTMLElement | Video element to render to. |
Returns:
Reference to the created renderer.
createMicrophone(deviceId, voiceInfo) → {Photon.Voice.AudioSource}
Creates microphone Photon.Voice.AudioSource.
Parameters:
Name | Type | Description |
---|---|---|
deviceId |
string | Microphone deviceId or empty string for the default microphone. Use 'navigator.mediaDevices.enumerateDevices()' to get a list of devices. |
voiceInfo |
Photon.Voice.VoiceInfo | Audio stream parameters. |
Returns:
Reference to the created audio source.
createOpusVoiceInfo(sampleRate, channels, frameDurationUs, bitrate) → {Photon.Voice.VoiceInfo}
Creates Photon.Voice.VoiceInfo for audio stream encoded with Opus.
Parameters:
Name | Type | Description |
---|---|---|
sampleRate |
number | Sample rate. |
channels |
number | Number of channels. |
frameDurationUs |
number | Packet duration in milliseconds: 10000, 20000, 40000, 60000. |
bitrate |
number | Bitrate in bits per sec. |
Returns:
Audio stream info.
createRemoteVoiceOptions(decoder, onRemove) → {Photon.Voice.RemoteVoiceOptions}
Creates an instance of RemoteVoiceOptions to return by the action called on a remote stream creation.
Parameters:
Name | Type | Description |
---|---|---|
decoder |
Photon.Voice.Decoder | The decoder to decode the remote stream with. |
onRemove |
Photon.Voice.RemoteVoiceOptionsOnRemoveAction | The action to execute on the remote voice removal. |
Returns:
Reference to the created options.
createScreenShareEncoder(info, videoElement) → {Photon.Voice.Encoder}
Creates a screenshare video source connected to a video encoder.
Parameters:
Name | Type | Description |
---|---|---|
info |
Photon.Voice.VoiceInfo | Stream parameters. |
videoElement |
HTMLVideoElement | Video element that drives the source and serves as a preview. |
Returns:
Reference to the created video encoder.
- Type
- Photon.Voice.Encoder
createTransport(lbc) → {Photon.Voice.LBTransport}
Creates an instance of Voice transport based on Photon.LoadBalancing.LoadBalancingClient.
Parameters:
Name | Type | Description |
---|---|---|
lbc |
Photon.LoadBalancing.LoadBalancingClient | LoadBalancingClient instance. |
Returns:
Reference to the created transport.
createVideoDecoder(voiceInfo, output) → {Photon.Voice.Decoder}
Creates video decoder.
Parameters:
Name | Type | Description |
---|---|---|
voiceInfo |
Photon.Voice.VoiceInfo | Stream parameters. |
output |
Photon.Voice.VideoDecoderCallback | Video fame output callback. |
Returns:
Reference to the created video decoder.
- Type
- Photon.Voice.Decoder
createVideoVoiceInfo(codec, bitrate, width, height, fps, keyFrameInt) → {Photon.Voice.VoiceInfo}
Creates video Photon.Voice.VoiceInfo object.
Parameters:
Name | Type | Description |
---|---|---|
codec |
Photon.Voice.Codec | Codec. |
bitrate |
number | Bitrate. |
width |
number | Frame width. |
height |
number | Frame height. |
fps |
number | Frames per second. |
keyFrameInt |
number | Keyframe interval in frames. |
Returns:
Video stream info.
createVoiceClient(transport) → {Photon.Voice.VoiceClient}
Creates Photon.Voice.VoiceClient.
Parameters:
Name | Type | Description |
---|---|---|
transport |
Photon.Voice.LBTransport | Reference to the transport instance. |
Returns:
Reference to the created Voice API Client.
dispose(obj)
Disposes the object created by Voice API.
Parameters:
Name | Type | Description |
---|---|---|
obj |
any | Reference to a Voice API object. |
setLogFunc(Log)
Sets Voice log function.
Parameters:
Name | Type | Description |
---|---|---|
Log |
Photon.Voice.LogFunc | function. |
setLogLevel(level)
Sets Voice logging level.
Parameters:
Name | Type | Description |
---|---|---|
level |
Photon.LogLevel | Log level. |
Type Definitions
AudioDecoderCallback(frame)
Parameters:
Name | Type | Description |
---|---|---|
frame |
Float32Array | Uncomressed audio frame. |
LogFunc(level, msg)
Parameters:
Name | Type | Description |
---|---|---|
level |
Photon.LogLevel | Logging level. |
msg |
string | Message to log. |
OnRemoteVoiceInfoAction(playerId, voiceId, voiceInfo) → {Photon.Voice.RemoteVoiceOptions}
Parameters:
Name | Type | Description |
---|---|---|
playerId |
number | Remote player id. |
voiceId |
number | Remote stream id. |
voiceInfo |
Photon.Voice.VoiceInfo | Remote stream parameters. |
Returns:
Options for the incoming stream processing.
RemoteVoiceOptionsOnRemoveAction()
VideoDecoderCallback(frame)
Parameters:
Name | Type | Description |
---|---|---|
frame |
Photon.Voice.VideoFrame | Uncomressed video frame. |