Re: [web-audio-api] Exclusive access to audio hardware (#72)

Updating my proposal:


## Interface Changes

### AudioContext

Add the concept of pausing and resuming to AudioContext.

 enum AudioContextPlayState {
  "playing",
  "paused",
  "interrupted"
 }

 partial interface AudioContext {
     readonly attribute AudioContextPlayState playState;
     attribute bool resumable;
     
     void pause();
     void resume();
 }
 
##### Algorithms

An AudioContext would start in the *"playing"* state.  An audio hardware interruption would move the state from *"playing"* to *"interrupted"*.  When interruption ends, if `resumable` is set to tue, the state would move from *"interrupted"* to *"playing"*.  Otherwise, it would move from *"interrupted"* to *"paused"*.

When the state is *"playing"*, `pause()` will move the state from *"playing"* to *"paused"*.  When the state is *"paused"*, calling `play()` will move the state from *"paused"* to *"playing"*.  If the audio hardware is unavailable, the state would move from *"playing"* to *"interrupted"*.

When the state is *"interrupted"*, both `play()` and `pause()` are no-ops.

When the state is *"interrupted"* or *"paused"*, the context's `currentTime` does not advance, and no audio is generated from any node.

##### Attributes

`playState`

+ A read-only attribute listing the current play state of the AudioContext. Valid values are *"playing"*, *"paused"*, and *"interrupted"*.

`resumable`

+ Defaults to `true`.  Controls whether audio resumes automatically after a hardware interruption ends.

##### Methods

`pause`

+ Changes the `playState` from *"playing"* to *"paused"*.

`resume`

+ Changes the `playState` from *"paused"* to *"playing"*.


---
Reply to this email directly or view it on GitHub:
https://github.com/WebAudio/web-audio-api/issues/72#issuecomment-24424663

Received on Friday, 13 September 2013 21:07:04 UTC