Skip to content

๐Ÿ’ก nuxt์—์„œ ๋ฐฐ๊ฒฝ์„ ๋น„๋””์˜ค๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

c-owner/corner-video-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Intro

auth : corner
date : 05-22

Descriptionโœ๏ธ

๐Ÿ’กNuxt์—์„œ Video๋ฅผ ๋ฐฐ๊ฒฝ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๋ช‡ ๊ฐ€์ง€ ์žˆ์ง€๋งŒ,

โ€‹ ํ”Œ๋ ˆ์ด์–ด์— ๋น„๋””์˜ค๋ฅผ ๋„ฃ๊ธฐ ์œ„ํ•ด์„œ๋Š” ํŒŒ์ผ์„ ์ง์ ‘ local์ด๋‚˜ ๋ฐฐํฌ๋˜๋Š” ์„œ๋ฒ„์— ์˜ฌ๋ฆฌ์ง€ ์•Š๊ณ  Cloudinary๋ผ๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์ œ์‹œํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

โ€‹ Nuxt์—์„œ Video๋ฅผ ๋ฐฐ๊ฒฝ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ด์ฃผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

img Github ์†Œ์Šค


Setup

1. ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

npm init nuxt-app project_name

nuxt.config.js ์— head์—๋‹ค๊ฐ€ script์™€ stylesheet๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

<!----------style-------------->
{ rel:  'stylesheet', href:  'https://unpkg.com/cloudinary-video-player@1.5.9/dist/cld-video-player.min.css' }
<!-- ------- script-------->
{ src:  'https://unpkg.com/cloudinary-core@latest/cloudinary-core-shrinkwrap.min.js'  },
{ src:  'https://unpkg.com/cloudinary-video-player@1.5.9/dist/cld-video-player.min.js'  }

2. .env ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

touch .env

example

NUXT_ENV_CLOUDINARY_CLOUD_NAME=username

CLOUDINARY_CLOUD_NAME์„ ์•Œ๋ ค๋Š” ๋ฐฉ๋ฒ•์€ ์ด๊ณณ์„ ์ฐธ์กฐํ•˜์„ธ์š”.

๋Œ€์‹œ๋ณด๋“œ์— ๋“ค์–ด๊ฐ€๋ฉด ํ™”๋ฉด์— Account Detail์— Cloud Name์„ ์•Œ๋ ค์ฃผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

Cloudinary์˜ ๊ณ„์ •์ด ์—†๋‹ค๋ฉด ๊นƒํ—ˆ๋ธŒ๋‚˜ ๊ตฌ๊ธ€์„ ์ด์šฉํ•ด์„œ ๊ฐ€์ž…์„ ํ•˜์‹œ๊ธธ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค.

3. Cloudinary์—์„œ Media Library ๋ฉ”๋‰ด๋กœ ์ด๋™ํ•˜์—ฌ Folder๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

Folder๋ช…์€ ์ž„์˜๋กœ ์ง€์ •ํ•˜๊ฑฐ๋‚˜, ์ฝ”๋“œ์ƒ์—์„œ public id๊ฐ’๊ณผ ๋™์ผํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Media Library์—์„œ nuxtjs-video-recommendations๋ผ๋Š” ํด๋”๋ช…์„ ์ƒ์„ฑํ•˜๊ณ , video๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

4. ์ถ”๊ฐ€ํ•œ ๋น„๋””์˜ค์— ๋‚˜์˜ค๋Š” ์ œ๋ชฉ์ด public Id = "ํด๋”๋ช…/๋น„๋””์˜ค์ œ๋ชฉ"์œผ๋กœ ์—ฐ๊ฒฐ๋˜๋Š” ๊ฒƒ์„ ์•Œ๊ณ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

5. ํ”„๋กœ์ ํŠธ๋กœ ๋“ค์–ด์™€์„œ ๋น„๋””์˜ค๊ฐ€ ๋“ค์–ด๊ฐ€์•ผ ํ•  ํŽ˜์ด์ง€์—์„œ ์ž‘์—…ํ•ฉ๋‹ˆ๋‹ค.

Index.vue

 <video
      id="recommendations-player"
      controls
      muted
      class="cld-video-player cld-video-player-skin-dark w-2/3 h-96 mx-auto"
    >
</video>
export default {
  name: 'IndexPage',
  data(){
    return {
      cld:null,
      player:null,
      source1: {
        publicId: "nuxtjs-video-recommendations/fireplace_bg_hoxtgx",
        title:'Night Street',
        subtitle:'Street at night with traffic and pedestrians',
        description:'Street at night with traffic and pedestrians'
      },
      source2: {
        publicId: "nuxtjs-video-recommendations/nightsky_bg_qt5bpq\n",
        title:'Cookie',
        subtitle:'Decorating a Cupcake with Gingerbread Cookie',
        description:'Decorating a Cupcake with Gingerbread Cookie'
      },

    };
  },
  mounted(){
    this.source1.recommendations = [
      this.source2
    ];

    this.cld = cloudinary.Cloudinary.new({
      cloud_name: process.env.NUXT_ENV_CLOUDINARY_CLOUD_NAME,
      secure: true,
      transformation: {crop: 'limit', width: 300, height:900}
    });

    this.player = this.cld.videoPlayer('recommendations-player',
      {
        autoShowRecommendations: true,
        sourceTypes: ['mp4']
      }
    );

    this.player.source(this.source1);
  }
}

source1, source2์˜ publicId ํ‚ค ๊ฐ’์— 3.๋ฒˆ๊ณผ 4.๋ฒˆ์—์„œ ๋งํ•œ ๊ฐ’์ด ๋“ค์–ด๊ฐ€์•ผํ•ฉ๋‹ˆ๋‹ค.

Attributes
์†์„ฑ ๊ธฐ๋Šฅ string
id this.cld.videoPlayer()์— ๋“ค์–ด๊ฐˆ id ๊ฐ’์ž…๋‹ˆ๋‹ค. bool
controls ํ”Œ๋ ˆ์ด์–ด์˜ ์ปจํŠธ๋กค ๊ธฐ๋Šฅ on/off ์—ฌ๋ถ€ bool
muted ์Œ์†Œ๊ฑฐ ๊ธฐ๋Šฅ bool
loop ๋ฌดํ•œ ๋ฃจํ”„ bool
...

๊ทธ์™ธ ์ถ”๊ฐ€ ์ ์ธ ์†์„ฑ์€ ์ถ”ํ›„ ์ž‘์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

About

๐Ÿ’ก nuxt์—์„œ ๋ฐฐ๊ฒฝ์„ ๋น„๋””์˜ค๋กœ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published