TP-0000| houston 3049 handled waveform error | Aman Singh (#480)
* TP-0000| houston 3049 handled waveform error | Aman Singh * TP-0000| submodule updated | Aman Singh * TP-0000| EM review | Aman Singh
This commit is contained in:
committed by
GitHub Enterprise
parent
542b603ad2
commit
e9961e43fc
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "web-ui-library"]
|
[submodule "web-ui-library"]
|
||||||
path = web-ui-library
|
path = web-ui-library
|
||||||
url = git@github.cmd.navi-tech.in:navi-commons/web-ui-library.git
|
url = git@github.com:navi-commons/web-ui-library.git
|
||||||
|
|||||||
@@ -62,3 +62,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loadingOrError {
|
||||||
|
position: absolute;
|
||||||
|
top: 65%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--navi-color-red-base);
|
||||||
|
animation: fadeIn 500ms;
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,10 +19,13 @@ interface IWaveform {
|
|||||||
|
|
||||||
let count = 0;
|
let count = 0;
|
||||||
const ID_PREFIX = '__waveform__list__item__';
|
const ID_PREFIX = '__waveform__list__item__';
|
||||||
|
const ERROR_MESSAGE = 'Error, loading audio file';
|
||||||
|
|
||||||
export const Waveform = ({ url }: IWaveform) => {
|
export const Waveform = ({ url }: IWaveform) => {
|
||||||
const waveForm = useRef<any>();
|
const waveForm = useRef<any>();
|
||||||
|
const timeout = useRef<NodeJS.Timeout>();
|
||||||
const [ready, setReady] = useState(false);
|
const [ready, setReady] = useState(false);
|
||||||
|
const [loadingOrError, setLoadingOrError] = useState('Loading ...');
|
||||||
const id = useRef<string>(`${ID_PREFIX}waveform_${++count}`);
|
const id = useRef<string>(`${ID_PREFIX}waveform_${++count}`);
|
||||||
const globalPlayerUrl = useSelector((state: RootState) => state?.common?.globalPlayer?.url);
|
const globalPlayerUrl = useSelector((state: RootState) => state?.common?.globalPlayer?.url);
|
||||||
const globalCursor = useSelector((state: RootState) => state?.common?.globalPlayer?.cursor || 0);
|
const globalCursor = useSelector((state: RootState) => state?.common?.globalPlayer?.cursor || 0);
|
||||||
@@ -91,7 +94,6 @@ export const Waveform = ({ url }: IWaveform) => {
|
|||||||
// console.trace('Waveform ERROR :: ', ex);
|
// console.trace('Waveform ERROR :: ', ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
waveForm?.current?.destroy();
|
waveForm?.current?.destroy();
|
||||||
};
|
};
|
||||||
@@ -119,26 +121,51 @@ export const Waveform = ({ url }: IWaveform) => {
|
|||||||
return url == globalPlayerUrl && globalPlaying;
|
return url == globalPlayerUrl && globalPlaying;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const shouldIBeVisible = () => {
|
||||||
|
clearTimeout(timeout.current);
|
||||||
|
timeout.current = setTimeout(() => setLoadingOrError(ERROR_MESSAGE), 5e3);
|
||||||
|
return waveForm.current?.getDuration();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wavesWrapper}>
|
<div className={styles.wavesWrapper}>
|
||||||
{
|
{
|
||||||
<div className={styles.secondsElapsed} style={{ visibility: ready ? 'visible' : 'none' }}>
|
<div className={styles.secondsElapsed} style={{ visibility: ready ? 'visible' : 'none' }}>
|
||||||
<span style={{ fontWeight: amIPlaying() ? 'bold' : '' }} className={styles.current}>
|
{shouldIBeVisible() ? (
|
||||||
{secondsToTimestamp(secondsElapsed)}
|
<>
|
||||||
</span>{' '}
|
<span style={{ fontWeight: amIPlaying() ? 'bold' : '' }} className={styles.current}>
|
||||||
/{' '}
|
{secondsToTimestamp(secondsElapsed)}
|
||||||
<span className={styles.duration}>
|
</span>{' '}
|
||||||
{secondsToTimestamp(waveForm?.current?.getDuration())}
|
/{' '}
|
||||||
</span>
|
<span className={styles.duration}>
|
||||||
|
{secondsToTimestamp(waveForm?.current?.getDuration())}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
) : loadingOrError === ERROR_MESSAGE ? (
|
||||||
|
'Unable to play'
|
||||||
|
) : (
|
||||||
|
'Loading ...'
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div className={styles.secondRow}>
|
<div className={styles.secondRow}>
|
||||||
<span onClick={handlePlayPause} className={styles.playPause}>
|
{shouldIBeVisible() ? (
|
||||||
{!amIPlaying() ? <Play /> : <Pause />}
|
<span onClick={handlePlayPause} className={styles.playPause}>
|
||||||
</span>
|
{!amIPlaying() ? <Play /> : <Pause />}
|
||||||
<div className={styles.waves} id={id.current}></div>
|
</span>
|
||||||
|
) : null}
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
pointerEvents: shouldIBeVisible() ? 'all' : 'none'
|
||||||
|
}}
|
||||||
|
className={styles.waves}
|
||||||
|
id={id.current}
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
{!shouldIBeVisible() && loadingOrError === ERROR_MESSAGE && (
|
||||||
|
<div className={styles.loadingOrError}>{loadingOrError}</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Submodule web-ui-library updated: 280715412a...f7c8485695
Reference in New Issue
Block a user