Skip to content

Commit a3334e2

Browse files
author
Rafael Miranda
committed
feat(player): Added new configuration element to set initial volume on media
1 parent d1953f1 commit a3334e2

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ var player = new OpenPlayer('[player ID]', [valid VAST/VPAID URL|List of VAST/VP
9090
// Number of seconds to rewind/forward media
9191
// (by default, player will rewind/forward 5% of the total duration of media)
9292
step,
93+
// Initial volume of media in decimal numbers (by default, `1`)
94+
startVolume,
9395
ads: {
9496
// Custom path/URL to IMA SDK
9597
url,

dist/openplayer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,7 @@ var Player = function () {
13701370
volumeControl: 'Volume Control',
13711371
volumeSlider: 'Volume Slider'
13721372
},
1373+
startVolume: 1,
13731374
step: 0
13741375
};
13751376
this.element = element instanceof HTMLMediaElement ? element : document.getElementById(element);
@@ -1378,8 +1379,9 @@ var Player = function () {
13781379
this.ads = ads;
13791380
this.fill = fill;
13801381
this.autoplay = this.element.autoplay || false;
1381-
this.volume = this.element.volume;
13821382
this.options = deepmerge(this.defaultOptions, options || {});
1383+
this.element.volume = this.options.startVolume;
1384+
this.volume = this.element.volume;
13831385
this.element.autoplay = false;
13841386
}
13851387

dist/openplayer.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/player.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ class Player {
253253
volumeControl: 'Volume Control',
254254
volumeSlider: 'Volume Slider',
255255
},
256+
startVolume: 1,
256257
step: 0,
257258
};
258259

@@ -272,8 +273,9 @@ class Player {
272273
this.ads = ads;
273274
this.fill = fill;
274275
this.autoplay = this.element.autoplay || false;
275-
this.volume = this.element.volume;
276276
this.options = deepmerge(this.defaultOptions, options || {});
277+
this.element.volume = this.options.startVolume;
278+
this.volume = this.element.volume;
277279
this.element.autoplay = false;
278280
}
279281
return this;

0 commit comments

Comments
 (0)