Skip to content

Commit 682b059

Browse files
committed
forced webgl on mobile
1 parent 68dbfef commit 682b059

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

examples/scripting/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
<div id="title-container">
1515
<h1>Diffusion Studio Examples</h1>
1616
<select name="scripts">
17+
<option value="font">Custom Font</option>
1718
<option value="filters">Filters</option>
1819
<option value="captions">Captions</option>
1920
<option value="drag-and-drop">Drag and Drop</option>
2021
<option value="custom-captions">Custiom Captions</option>
21-
<option value="font">Custom Font</option>
2222
<option value="split-video">Split Video</option>
2323
<option value="video-trimming">Video Trimming</option>
2424
<option value="reddit-stories">Reddit Stories</option>

examples/scripting/src/borwser-support.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ if (!isSupported) {
1212
const el = document.querySelector('[id="browser-not-supported"]') as HTMLParagraphElement;
1313
el.style.display = 'block';
1414
}
15+
16+
export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);

examples/scripting/src/main.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@diffusionstudio/core';
22
import { MainFn, Settings } from './types';
3-
import './borwser-support';
3+
import { isMobile } from './borwser-support';
44

55
const select = document.querySelector('select') as HTMLSelectElement;
66
const container = document.querySelector('[id="player-container"]') as HTMLDivElement;
@@ -19,7 +19,10 @@ async function loadScript(name: string) {
1919
const module = await import(`./${name}.ts`);
2020
const main: MainFn = module.main;
2121
const settings: Settings = module.settings;
22-
const composition = new core.Composition(settings);
22+
const composition = new core.Composition({
23+
...settings, // force webgl on mobile
24+
backend: isMobile ? 'webgl' : undefined
25+
});
2326
await main(composition);
2427

2528
const handlePlay = () => composition.play();
@@ -66,7 +69,7 @@ async function loadScript(name: string) {
6669

6770
return () => {
6871
composition.pause();
69-
72+
7073
playButton.removeEventListener('click', handlePlay);
7174
pauseButton.removeEventListener('click', handlePause);
7275
backButton.removeEventListener('click', handleBack);

0 commit comments

Comments
 (0)