Implements volume and playback options for video widget (both for html video and youtube)

This commit is contained in:
Hadi Nategh 2021-08-13 12:39:38 +02:00
parent 3ea863c5bc
commit a7ea5b51bf

View File

@ -96,6 +96,18 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
"type": "boolean",
"default": false,
"description": "Defines if the video should be played repeatedly"
},
"volume": {
"name": "Video volume",
"type": "float",
"default": 0,
"description": "Set video's volume"
},
"playbackrate": {
"name": "Video playBackRate",
"type": "float",
"default": 1,
"description": "Set video's playBackRate"
}
};
@ -264,6 +276,77 @@ export class et2_video extends et2_baseWidget implements et2_IDOMNode
}
}
/**
* Method to set volume
* @param _value
*/
set_volume(_value: number)
{
let value = _value>100?100:_value;
if (value>= 0)
{
if (this._isYoutube())
{
this.youtube.set_volume(value);
}
else
{
this.video[0].volume = value/100;
}
}
}
/**
* get volume
*/
get_volume()
{
if (this._isYoutube())
{
return this.youtube.get_playBackRate();
}
else
{
return this.video[0].playBackRate;
}
}
/**
* method to set playBackRate
* @param _value
*/
set_playBackRate(_value: number)
{
let value = _value>16?16:_value;
if (value>= 0)
{
if (this._isYoutube())
{
this.youtube.playBackRate(value);
}
else
{
this.video[0].playBackRate = value;
}
}
}
/**
* get playBackRate
*/
get_playBackRate()
{
if (this._isYoutube())
{
return this.youtube.get_volume();
}
else
{
return this.video[0].volume;
}
}
}
/**
* Set poster attribute in order to specify
* an image to be shown while video is loading or before user play it