Navigation Menu

Skip to content

Commit

Permalink
- startVolume works better in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
johndyer committed May 19, 2011
1 parent ae8d846 commit 76a46a2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/flash/FlashMediaElement.as
Expand Up @@ -33,6 +33,7 @@
private var _enableSmoothing:Boolean;
private var _allowedPluginDomain:String;
private var _isFullScreen:Boolean = false;
private var _startVolume:Number;

// native video size (from meta data)
private var _nativeVideoWidth:Number = 0;
Expand Down Expand Up @@ -75,6 +76,7 @@
_timerRate = (params['timerrate'] != undefined) ? (parseInt(params['timerrate'], 10)) : 250;
_showControls = (params['controls'] != undefined) ? (String(params['controls']) == "true") : false;
_enableSmoothing = (params['smoothing'] != undefined) ? (String(params['smoothing']) == "true") : false;
_startVolume = (params['startvolume'] != undefined) ? (parseInt(params['startvolume'], 10)) : 1;

if (isNaN(_timerRate))
_timerRate = 250;
Expand Down Expand Up @@ -104,15 +106,15 @@

// create media element
if (_isVideo) {
_mediaElement = new VideoElement(this, _autoplay, _timerRate);
_mediaElement = new VideoElement(this, _autoplay, _timerRate, _startVolume);
_video = (_mediaElement as VideoElement).video;
_video.width = _stageWidth;
_video.height = _stageHeight;
_video.smoothing = _enableSmoothing;
//_video.scaleMode = VideoScaleMode.MAINTAIN_ASPECT_RATIO;
addChild(_video);
} else {
_mediaElement = new AudioElement(this, _autoplay, _timerRate);
_mediaElement = new AudioElement(this, _autoplay, _timerRate, _startVolume);
}

// debugging
Expand Down
5 changes: 3 additions & 2 deletions src/flash/htmlelements/AudioElement.as
Expand Up @@ -54,15 +54,16 @@ package htmlelements
return _currentTime;
}

public function AudioElement(element:FlashMediaElement, autoplay:Boolean, timerRate:Number)
public function AudioElement(element:FlashMediaElement, autoplay:Boolean, timerRate:Number, startVolume:Number)
{
_element = element;
_autoplay = autoplay;
_volume = startVolume;

_timer = new Timer(timerRate);
_timer.addEventListener(TimerEvent.TIMER, timerEventHandler);

_soundTransform = new SoundTransform();
_soundTransform = new SoundTransform(_volume);
_soundLoaderContext = new SoundLoaderContext();
}

Expand Down
3 changes: 2 additions & 1 deletion src/flash/htmlelements/VideoElement.as
Expand Up @@ -77,10 +77,11 @@
// _stream gets created


public function VideoElement(element:FlashMediaElement, autoplay:Boolean, timerRate:Number)
public function VideoElement(element:FlashMediaElement, autoplay:Boolean, timerRate:Number, startVolume:Number)
{
_element = element;
_autoplay = autoplay;
_volume = startVolume;

_video = new Video();
addChild(_video);
Expand Down
1 change: 1 addition & 0 deletions src/js/me-shim.js
Expand Up @@ -343,6 +343,7 @@ mejs.HtmlMediaElementShim = {
'autoplay=' + ((autoplay) ? "true" : "false"),
'preload=' + preload,
'width=' + width,
'startvolume=' + options.startVolume,
'timerrate=' + options.timerRate,
'height=' + height];

Expand Down
4 changes: 4 additions & 0 deletions src/silverlight/MainPage.xaml.cs
Expand Up @@ -34,6 +34,7 @@ public partial class MainPage : UserControl
int _timerRate = 0;
double _bufferedBytes = 0;
double _bufferedTime = 0;
double _volume = 1;
int _videoWidth = 0;
int _videoHeight = 0;

Expand Down Expand Up @@ -74,6 +75,8 @@ public MainPage(IDictionary<string, string> initParams)
Int32.TryParse(initParams["height"], out _height);
if (initParams.ContainsKey("timerate"))
Int32.TryParse(initParams["timerrate"], out _timerRate);
if (initParams.ContainsKey("startvolume"))
Double.TryParse(initParams["startvolume"], out _volume);

if (_timerRate == 0)
_timerRate = 250;
Expand Down Expand Up @@ -101,6 +104,7 @@ public MainPage(IDictionary<string, string> initParams)


media.AutoPlay = _autoplay;
media.Volume = _volume;
if (!String.IsNullOrEmpty(_mediaUrl)) {
setSrc(_mediaUrl);
if (_autoplay)
Expand Down

0 comments on commit 76a46a2

Please sign in to comment.