mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Implemented JS API for setValueCurveAtTime and updated tests
This commit is contained in:
parent
94c1551c8f
commit
b519a0b941
7 changed files with 220 additions and 14 deletions
|
@ -231,6 +231,40 @@ impl AudioParamMethods for AudioParam {
|
|||
Ok(DomRoot::from_ref(self))
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioparam-setvaluecurveattime
|
||||
fn SetValueCurveAtTime(
|
||||
&self,
|
||||
values: Vec<Finite<f32>>,
|
||||
start_time: Finite<f64>,
|
||||
end_time: Finite<f64>,
|
||||
) -> Fallible<DomRoot<AudioParam>> {
|
||||
if *start_time < 0. {
|
||||
return Err(Error::Range(format!(
|
||||
"start time {} should not be negative",
|
||||
*start_time
|
||||
)));
|
||||
}
|
||||
if values.len() < 2. as usize {
|
||||
return Err(Error::InvalidState);
|
||||
}
|
||||
|
||||
if *end_time < 0. {
|
||||
return Err(Error::Range(format!(
|
||||
"end time {} should not be negative",
|
||||
*end_time
|
||||
)));
|
||||
}
|
||||
self.message_node(AudioNodeMessage::SetParam(
|
||||
self.param,
|
||||
UserAutomationEvent::SetValueCurveAtTime(
|
||||
values.into_iter().map(|v| *v).collect(),
|
||||
*start_time,
|
||||
*end_time,
|
||||
),
|
||||
));
|
||||
Ok(DomRoot::from_ref(self))
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioparam-cancelscheduledvalues
|
||||
fn CancelScheduledValues(&self, cancel_time: Finite<f64>) -> Fallible<DomRoot<AudioParam>> {
|
||||
if *cancel_time < 0. {
|
||||
|
|
|
@ -24,9 +24,9 @@ interface AudioParam {
|
|||
[Throws] AudioParam setTargetAtTime(float target,
|
||||
double startTime,
|
||||
float timeConstant);
|
||||
// AudioParam setValueCurveAtTime(sequence<float> values,
|
||||
// double startTime,
|
||||
// double duration);
|
||||
[Throws] AudioParam setValueCurveAtTime(sequence<float> values,
|
||||
double startTime,
|
||||
double duration);
|
||||
[Throws] AudioParam cancelScheduledValues(double cancelTime);
|
||||
[Throws] AudioParam cancelAndHoldAtTime(double cancelTime);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue