forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#38302 from software-mansion-labs/@Skalak…
…id/fix-ios-safari-video-thumbnails Fix video file preview not displaying after selecting video from device gallery
- Loading branch information
Showing
3 changed files
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
// Converts milliseconds to '[hours:]minutes:seconds' format | ||
const convertMillisecondsToTime = (milliseconds: number) => { | ||
/** | ||
* Converts milliseconds to '[hours:]minutes:seconds' format | ||
*/ | ||
function convertMillisecondsToTime(milliseconds: number) { | ||
const hours = Math.floor(milliseconds / 3600000); | ||
const minutes = Math.floor((milliseconds / 60000) % 60); | ||
const seconds = Math.floor((milliseconds / 1000) % 60) | ||
.toFixed(0) | ||
.padStart(2, '0'); | ||
return hours > 0 ? `${hours}:${String(minutes).padStart(2, '0')}:${seconds}` : `${minutes}:${seconds}`; | ||
}; | ||
} | ||
|
||
export default convertMillisecondsToTime; | ||
/** | ||
* Adds a #t=seconds tag to the end of the URL to skip first seconds of the video | ||
*/ | ||
function addSkipTimeTagToURL(url: string, seconds: number) { | ||
if (url.includes('#t=')) { | ||
return url; | ||
} | ||
return `${url}#t=${seconds}`; | ||
} | ||
|
||
export {convertMillisecondsToTime, addSkipTimeTagToURL}; |