MediaTrackSettings: sampleRate property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
TheMediaTrackSettings dictionary'ssampleRate property is an integer indicating how manyaudio samples per second theMediaStreamTrack is currently configuredfor. This lets you determine what value was selected to comply with your specifiedconstraints for this property's value as described in theMediaTrackConstraints.sampleRate property you provided when callingeithergetUserMedia() orMediaStreamTrack.applyConstraints().
If needed, you can determine whether or not this constraint is supported by checkingthe value ofMediaTrackSupportedConstraints.sampleRate as returned by acall toMediaDevices.getSupportedConstraints(). However, typically thisis unnecessary since browsers will ignore any constraints they're unfamiliar with.
In this article
Value
An integer value indicating how many samples each second of audio data includes. Commonvalues include 44,100 (standard CD audio), 48,000 (standard digital audio), 96,000(commonly used in audio mastering and post-production), and 192,000 (used forhigh-resolution audio in professional recording and mastering sessions). However, lowervalues are often used to reduce bandwidth requirements; 8,000 samples per second isadequate for comprehensible albeit imperfect human speech, and both 11,025 FPS and22,050 FPS are often used for low-bandwidth, reduced quality sound and music.
Examples
See theConstraint exerciser example.
Specifications
| Specification |
|---|
| Media Capture and Streams> # dom-mediatrackconstraintset-samplerate> |