Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active February 14, 2019 19:03
Show Gist options
  • Save productioncoder/0b66b46840f5b2391e8d7c62c2683845 to your computer and use it in GitHub Desktop.
Save productioncoder/0b66b46840f5b2391e8d7c62c2683845 to your computer and use it in GitHub Desktop.
Youtube VideoPreview with correct video duration formatting
/*...*/
import {getVideoDurationString} from '../../services/date/date-format';
export class VideoPreview extends React.Component {
render() {
/* ... */
const duration = video.contentDetails ? video.contentDetails.duration : null;
const videoDuration = getVideoDurationString(duration);
const viewAndTimeString = VideoPreview.getFormattedViewAndTime(video);
const horizontal = this.props.horizontal ? 'horizontal' : null;
return (
{/*...*/}
<div className='time-label'>
<span>{videoDuration}</span>
</div>
{/*... */}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment