[REF] mail: move DOM function to view model

Since the addition of the CallParticipantVideoView model, it makes more
sense to have this view(DOM) related function in it.

closes odoo/odoo#93260

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Thanh Dodeur
2022-06-10 11:26:20 +02:00
parent 529bab8f0b
commit 307cec490a
3 changed files with 18 additions and 18 deletions
@@ -8,7 +8,7 @@
playsinline="true"
autoplay="true"
muted="true"
t-on-loadedmetadata="callParticipantVideoView.rtcSession.onVideoLoadedMetaData"
t-on-loadedmetadata="callParticipantVideoView.onVideoLoadedMetaData"
t-ref="root"
/>
</t>
@@ -8,6 +8,23 @@ registerModel({
name: 'CallParticipantVideoView',
identifyingFields: ['callParticipantCardOwner'],
recordMethods: {
/**
* Plays the video as some browsers may not support or block autoplay.
*
* @param {Event} ev
*/
async onVideoLoadedMetaData(ev) {
try {
await ev.target.play();
} catch (error) {
if (typeof error === 'object' && error.name === 'NotAllowedError') {
// Ignored as some browsers may reject play() calls that do not
// originate from a user input.
return;
}
throw error;
}
},
/**
* @private
* @returns {FieldCommand}
@@ -13,23 +13,6 @@ registerModel({
},
},
recordMethods: {
/**
* Plays the video as some browsers may not support or block autoplay.
*
* @param {Event} ev
*/
async onVideoLoadedMetaData(ev) {
try {
await ev.target.play();
} catch (error) {
if (typeof error === 'object' && error.name === 'NotAllowedError') {
// Ignored as some browsers may reject play() calls that do not
// originate from a user input.
return;
}
throw error;
}
},
/**
* restores the session to its default values
*/