From ddda69148bc587dfc093e162998aa2ef89172dd3 Mon Sep 17 00:00:00 2001 From: "ananta@chromium.org" Date: Mon, 17 Nov 2008 19:44:36 +0000 Subject: Translate volume information passed to the instance of Windows media player instantiated by the Activex shim. The Activex shim gets instantiated as a NPAPI plugin, which hosts the Media player activex. Volume defaults differ between the media player NPAPI plugin and the Activex. Fixes bug http://code.google.com/p/chromium/issues/detail?id=1163 R=amit Bug=1163 Review URL: http://codereview.chromium.org/11409 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5563 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/activex_shim/activex_plugin.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/webkit/activex_shim/activex_plugin.cc b/webkit/activex_shim/activex_plugin.cc index 33d417e..ae638a3 100644 --- a/webkit/activex_shim/activex_plugin.cc +++ b/webkit/activex_shim/activex_plugin.cc @@ -93,12 +93,28 @@ void ActiveXPlugin::ConvertForEmbeddedWmp() { ControlParam* existing_url_param = NULL; std::wstring src; // Find the src parameter and use it to add a new url parameter. + // Find the volume parameter and setup defaults which make sense in + // the Activex media player world. for (unsigned int i = 0; i < params_.size(); i++) { - if (LowerCaseEqualsASCII(params_[i].name, "src")) + if (LowerCaseEqualsASCII(params_[i].name, "src")) { src = params_[i].value; - else if (LowerCaseEqualsASCII(params_[i].name, "url")) + } else if (LowerCaseEqualsASCII(params_[i].name, "url")) { existing_url_param = ¶ms_[i]; + } else if (LowerCaseEqualsASCII(params_[i].name, "volume")) { + // In the NPAPI media player world a volume value lesser than + // -3000 turns off the volume. A volume value of 0 indicates + // full volume. Translate these to their Activex counterparts. + int specified_volume = 0; + if (StringToInt(params_[i].value, &specified_volume)) { + // Valid volume lies between 0 and -3000 + specified_volume = std::min (0, std::max(-3000, specified_volume)); + // Translate to a value between 0 and 100. + int activex_volume = specified_volume / 30 + 100; + params_[i].value = IntToWString(activex_volume); + } + } } + if (!src.empty()) { if (existing_url_param == NULL) params_.push_back(ControlParam(L"url", src)); -- cgit v1.1