Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@xibosignage/xibo-layout-renderer",
"version": "1.0.37",
"version": "1.0.38",
"description": "Xibo layout renderer is a shared library that performs rendering of given layout from sources (e.g. CMS Preview, Linux Player, etc.)",
"main": "dist/xibo-layout-renderer.cjs.js",
"module": "dist/xibo-layout-renderer.esm.js",
Expand Down
7 changes: 5 additions & 2 deletions src/Modules/Generators/Generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ export function composeResourceUrlByPlatform(options: OptionsType, params: any)
'_region_' + params.regionId +
'_media_' + params.mediaId +
'.html';
} else if (params.render === 'native' && params.isImageOrVideo) {
} else if (params.render === 'native' && (params.isImageOrVideo || params.isAudio)) {
// Native media is played straight from the consumer's local file server.
resourceUrl = options.appHost + params.uri;
}
} else if (!Boolean(params['mediaType'])) {
Expand Down Expand Up @@ -572,7 +573,9 @@ export function prepareAudio(media: IMedia, container: HTMLAudioElement) {

$audioMedia.preload = 'auto';
$audioMedia.textContent = 'Unsupported Audio';
$audioMedia.autoplay = true;
// AudioMedia starts it when its turn comes. Autoplay would start it as soon as it has a source,
// which is while its layout is still being prepared behind the one on screen.
$audioMedia.autoplay = false;

if (media.loop) {
$audioMedia.loop = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/Layout/Layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ export default class Layout implements ILayout {
this.xw = Number(this.layoutNode?.firstElementChild?.getAttribute('width'));
this.xh = Number(this.layoutNode?.firstElementChild?.getAttribute('height'));
this.zIndex = Number(this.layoutNode?.firstElementChild?.getAttribute('zindex')) || 0;
this.enableStat = Boolean(this.layoutNode?.firstElementChild?.getAttribute('enableStat') || false);
this.enableStat = this.layoutNode?.firstElementChild?.getAttribute('enableStat') === '1';

/* Calculate Scale Factor */
this.scaleFactor = Math.min((this.sw / this.xw), (this.sh / this.xh));
Expand Down
8 changes: 7 additions & 1 deletion src/Modules/Media/Media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class Media implements IMedia {
this.mediaType = this.xml?.getAttribute('type') || '';
this.render = this.xml?.getAttribute('render') || '';
this.duration = parseInt(this.xml?.getAttribute('duration') as string) || 0;
this.enableStat = Boolean(this.xml?.getAttribute('enableStat') || false);
this.enableStat = this.xml?.getAttribute('enableStat') === '1';
this.hasCommandExecuted = false;
this.fromDt = this.xml?.getAttribute('fromDt') || '';
this.toDt = this.xml?.getAttribute('toDt') || '';
Expand Down Expand Up @@ -435,6 +435,7 @@ export class Media implements IMedia {
uri: this.uri,
isGlobalContent: this.mediaType === 'global',
isImageOrVideo: this.mediaType === 'image' || this.mediaType === 'video',
isAudio: this.mediaType === 'audio',
render: this.render,
modeid: this.options['modeid'],
// XLF option node names are lower-cased when parsed above, so the
Expand Down Expand Up @@ -688,6 +689,11 @@ export class Media implements IMedia {

async stop() {
if (this.html) {
// Audio has nothing on screen to hide, so make sure it falls silent too.
if (this.html instanceof HTMLAudioElement) {
this.html.pause();
}

this.html.style.display = 'none';
this.html.remove();
}
Expand Down
26 changes: 16 additions & 10 deletions src/Modules/Region/Region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,20 +464,26 @@ export default class Region implements IRegion {
$oldMedia.style.setProperty('z-index', '-999');
$oldMedia.style.setProperty('opacity', '0');

let $videoWrapper = null;
let $videoWrapper: HTMLElement | null = null;
if (oldMedia.mediaType === 'video') {
// @ts-ignore
if ($oldMedia !== null && $oldMedia?.parentElement?.classList.contains('video-js')) {
// video.js moves the media's class onto the wrapper it builds around the
// <video>, so the element found above is usually the wrapper itself.
// Missing it skipped stop(true) below, and a player held for this
// transition was never disposed: it stayed registered in video.js, with
// its <video> and source, for every playlist cycle.
if ($oldMedia.classList.contains('video-js')) {
$videoWrapper = $oldMedia;
} else if ($oldMedia.parentElement?.classList.contains('video-js')) {
$videoWrapper = $oldMedia.parentElement;
}

if ($videoWrapper !== null) {
$videoWrapper.style.setProperty('visibility', 'hidden');
$videoWrapper.style.setProperty('z-index', '-999');
$videoWrapper.style.setProperty('opacity', '0');
if ($videoWrapper !== null) {
$videoWrapper.style.setProperty('visibility', 'hidden');
$videoWrapper.style.setProperty('z-index', '-999');
$videoWrapper.style.setProperty('opacity', '0');

if (oldMedia.videoHandler) {
oldMedia.videoHandler.stop(true);
}
if (oldMedia.videoHandler) {
oldMedia.videoHandler.stop(true);
}
}
}
Expand Down
Loading