зеркало из https://github.com/mozilla/gecko-dev.git
Bug 925594 - WebIDL enum for AudioChannel in HTMLMediaElement, r=ehsan, r=khuey
This commit is contained in:
Родитель
7a574949b8
Коммит
028b3d33fb
|
@ -17,6 +17,7 @@
|
|||
#include "DecoderTraits.h"
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "mozilla/dom/TextTrackManager.h"
|
||||
|
||||
// Define to output information on decoding and painting framerate
|
||||
|
@ -513,12 +514,8 @@ public:
|
|||
|
||||
double MozFragmentEnd();
|
||||
|
||||
// XPCOM GetMozAudioChannelType() is OK
|
||||
|
||||
void SetMozAudioChannelType(const nsAString& aValue, ErrorResult& aRv)
|
||||
{
|
||||
SetHTMLAttr(nsGkAtoms::mozaudiochannel, aValue, aRv);
|
||||
}
|
||||
AudioChannel MozAudioChannelType() const;
|
||||
void SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv);
|
||||
|
||||
TextTrackList* TextTracks() const;
|
||||
|
||||
|
|
|
@ -3928,5 +3928,41 @@ HTMLMediaElement::PopulatePendingTextTrackList()
|
|||
}
|
||||
}
|
||||
|
||||
AudioChannel
|
||||
HTMLMediaElement::MozAudioChannelType() const
|
||||
{
|
||||
switch (mAudioChannelType) {
|
||||
case AUDIO_CHANNEL_CONTENT:
|
||||
return AudioChannel::Content;
|
||||
|
||||
case AUDIO_CHANNEL_NOTIFICATION:
|
||||
return AudioChannel::Notification;
|
||||
|
||||
case AUDIO_CHANNEL_ALARM:
|
||||
return AudioChannel::Alarm;
|
||||
|
||||
case AUDIO_CHANNEL_TELEPHONY:
|
||||
return AudioChannel::Telephony;
|
||||
|
||||
case AUDIO_CHANNEL_RINGER:
|
||||
return AudioChannel::Ringer;
|
||||
|
||||
case AUDIO_CHANNEL_PUBLICNOTIFICATION:
|
||||
return AudioChannel::Publicnotification;
|
||||
|
||||
default:
|
||||
return AudioChannel::Normal;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
|
||||
{
|
||||
nsString channel;
|
||||
channel.AssignASCII(AudioChannelValues::strings[uint32_t(aValue)].value,
|
||||
AudioChannelValues::strings[uint32_t(aValue)].length);
|
||||
SetHTMLAttr(nsGkAtoms::mozaudiochannel, channel, aRv);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -43,7 +43,7 @@ ok(audio3.mozAudioChannelType == "content", "Default audio3 channel == 'content'
|
|||
try {
|
||||
audio3.mozAudioChannelType = "foo";
|
||||
} catch(e) {}
|
||||
ok(audio3.mozAudioChannelType == "normal", "audio3 channel == 'normal'");
|
||||
ok(audio3.mozAudioChannelType == "content", "audio3 channel == 'content'");
|
||||
audio3.mozAudioChannelType = "alarm";
|
||||
ok(audio3.mozAudioChannelType == "alarm", "audio3 channel == 'alarm'");
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef AudioContext_h_
|
||||
#define AudioContext_h_
|
||||
|
||||
#include "mozilla/dom/AudioContextBinding.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "EnableWebAudioCheck.h"
|
||||
#include "MediaBufferDecoder.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#ifndef AudioDestinationNode_h_
|
||||
#define AudioDestinationNode_h_
|
||||
|
||||
#include "mozilla/dom/AudioContextBinding.h"
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "AudioNode.h"
|
||||
#include "nsIDOMEventListener.h"
|
||||
#include "nsIAudioChannelAgent.h"
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
// AudioChannels are used by:
|
||||
// * HTMLMediaElement
|
||||
// * AudioContext (WebAudio)
|
||||
// When used, it has to throw an exception if the app tries to change the audio
|
||||
// channel type without the permission (manifest file for B2G apps).
|
||||
// The supported values are:
|
||||
// * normal (default value)
|
||||
// Automatically paused if "notification" or higher priority channel
|
||||
// is played
|
||||
// Use case: normal applications
|
||||
// * content
|
||||
// Automatically paused if "notification" or higher priority channel
|
||||
// is played. Also paused if another app starts using "content"
|
||||
// channel. Using this channel never affects applications using
|
||||
// the "normal" channel.
|
||||
// Use case: video/audio players
|
||||
// * notification
|
||||
// Automatically paused if "alarm" or higher priority channel is played.
|
||||
// Use case: New email, incoming SMS
|
||||
// * alarm
|
||||
// Automatically paused if "telephony" or higher priority channel is
|
||||
// played.
|
||||
// User case: Alarm clock, calendar alarms
|
||||
// * telephony
|
||||
// Automatically paused if "ringer" or higher priority
|
||||
// channel is played.
|
||||
// Use case: dialer, voip
|
||||
// * ringer
|
||||
// Automatically paused if "publicnotification" or higher priority
|
||||
// channel is played.
|
||||
// Use case: dialer, voip
|
||||
// * publicnotification
|
||||
// Always plays in speaker, even when headphones are plugged in.
|
||||
// Use case: Camera shutter sound.
|
||||
enum AudioChannel {
|
||||
"normal",
|
||||
"content",
|
||||
"notification",
|
||||
"alarm",
|
||||
"telephony",
|
||||
"ringer",
|
||||
"publicnotification",
|
||||
};
|
|
@ -98,19 +98,9 @@ partial interface AudioContext {
|
|||
optional unsigned long numberOfOutputChannels = 2);
|
||||
};
|
||||
|
||||
enum AudioChannel {
|
||||
"normal",
|
||||
"content",
|
||||
"notification",
|
||||
"alarm",
|
||||
"telephony",
|
||||
"ringer",
|
||||
"publicnotification",
|
||||
};
|
||||
|
||||
// Mozilla extensions
|
||||
partial interface AudioContext {
|
||||
// Read HTMLMediaElement.webidl for more information about this attribute.
|
||||
// Read AudioChannel.webidl for more information about this attribute.
|
||||
[Pref="media.useAudioChannelService", SetterThrows]
|
||||
attribute AudioChannel mozAudioChannelType;
|
||||
};
|
||||
|
|
|
@ -133,39 +133,9 @@ partial interface HTMLMediaElement {
|
|||
readonly attribute double mozFragmentEnd;
|
||||
|
||||
// Mozilla extension: an audio channel type for media elements.
|
||||
// An exception is thrown if the app tries to change the audio channel type
|
||||
// without the permission (manifest file for B2G apps).
|
||||
// The supported values are:
|
||||
// * normal (default value)
|
||||
// Automatically paused if "notification" or higher priority channel
|
||||
// is played
|
||||
// Use case: normal applications
|
||||
// * content
|
||||
// Automatically paused if "notification" or higher priority channel
|
||||
// is played. Also paused if another app starts using "content"
|
||||
// channel. Using this channel never affects applications using
|
||||
// the "normal" channel.
|
||||
// Use case: video/audio players
|
||||
// * notification
|
||||
// Automatically paused if "alarm" or higher priority channel is played.
|
||||
// Use case: New email, incoming SMS
|
||||
// * alarm
|
||||
// Automatically paused if "telephony" or higher priority channel is
|
||||
// played.
|
||||
// User case: Alarm clock, calendar alarms
|
||||
// * telephony
|
||||
// Automatically paused if "ringer" or higher priority
|
||||
// channel is played.
|
||||
// Use case: dialer, voip
|
||||
// * ringer
|
||||
// Automatically paused if "publicnotification" or higher priority
|
||||
// channel is played.
|
||||
// Use case: dialer, voip
|
||||
// * publicnotification
|
||||
// Always plays in speaker, even when headphones are plugged in.
|
||||
// Use case: Camera shutter sound.
|
||||
// Read AudioChannel.webidl for more information about this attribute.
|
||||
[SetterThrows]
|
||||
attribute DOMString mozAudioChannelType;
|
||||
attribute AudioChannel mozAudioChannelType;
|
||||
|
||||
// In addition the media element has this new events:
|
||||
// * onmozinterruptbegin - called when the media element is interrupted
|
||||
|
|
|
@ -26,6 +26,7 @@ WEBIDL_FILES = [
|
|||
'Attr.webidl',
|
||||
'AudioBuffer.webidl',
|
||||
'AudioBufferSourceNode.webidl',
|
||||
'AudioChannel.webidl',
|
||||
'AudioContext.webidl',
|
||||
'AudioDestinationNode.webidl',
|
||||
'AudioListener.webidl',
|
||||
|
|
Загрузка…
Ссылка в новой задаче