Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: video dimension bugs, extra spacing #243

Merged
merged 1 commit into from
Apr 19, 2024
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 examples/default-provider/app/background-video/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Metadata } from 'next';
import BackgroundVideo from 'next-video/background-video';
import getStarted from '/videos/country-clouds.mp4?thumbnailTime=0';
import countryClouds from '/videos/country-clouds.mp4?thumbnailTime=0';

export const metadata: Metadata = {
title: 'next-video - Background Video',
Expand All @@ -10,7 +10,7 @@ export default function Page() {
return (
<>
<section>
<BackgroundVideo src={getStarted} disableTracking>
<BackgroundVideo src={countryClouds} disableTracking>
<h1>next-video</h1>
<p>
A React component for adding video to your Next.js application.
Expand Down
8 changes: 6 additions & 2 deletions examples/default-provider/app/custom-player/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Metadata } from 'next';
import Video from 'next-video';
import ReactPlayer from './player'
import getStarted from '/videos/country-clouds.mp4';
import countryClouds from '/videos/country-clouds.mp4';

export const metadata: Metadata = {
title: 'next-video - Custom Player',
Expand All @@ -11,7 +11,11 @@ export default function Page() {
return (
<>
<section>
<Video as={ReactPlayer} src={getStarted} />
<Video
as={ReactPlayer}
src={countryClouds}
style={{ aspectRatio: 1.9 }}
/>
</section>
</>
);
Expand Down
13 changes: 7 additions & 6 deletions src/components/players/background-player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,32 @@ export const BackgroundPlayer = forwardRef((allProps: BackgroundPlayerProps, for
.next-video-bg {
aspect-ratio: initial;
height: 100%;
display: grid;
}

.next-video-bg [data-next-video],
.next-video-bg-poster,
.next-video-bg-text {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
grid-area: 1 / 1;
}

.next-video-bg-poster {
position: relative;
object-fit: cover;
pointer-events: none;
transition: opacity .25s;
}

.next-video-bg-poster[hidden] {
display: none;
opacity: 0;
}

.next-video-bg [data-next-video] {
object-fit: cover;
}

.next-video-bg-text {
position: relative;
display: grid;
place-content: center;
padding: 5% 5% 10%;
Expand Down
5 changes: 2 additions & 3 deletions src/components/video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,18 @@ const NextVideo = forwardRef((props: VideoProps, forwardedRef) => {
return (
<div className={`${className ? `${className} ` : ''}next-video-container`} style={style}>
<style>{
/* css */ `
/* css */`
.next-video-container {
position: relative;
width: 100%;
aspect-ratio: 16 / 9;
}

[data-next-video] {
display: block;
position: relative;
width: 100%;
height: 100%;
display: inline-block;
line-height: 0;
}

[data-next-video] img {
Expand Down