npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

shuvi-lib

v1.0.6

Published

YouTube IFrame Player APIをゆるふわにラッピングしたライブラリ「shuvi-lib」

Readme

shuvi-lib

shuvi-libは、YouTube IFrame Player APIをゆるふわにラッピングしたライブラリです。

shuvi-lib

Download

shuvi-libの使う方法はいくつかあります。

一つ目は、GitHubページからダウンロードして自分のプロジェクトに置き、使う方法。

二つ目は、shuvi-libはnpm上で公開されているので、

npm install shuvi-lib

のようにnpmコマンドを使ってプロジェクトに取り込む方法。

三つ目は、私、yuki540のサーバー経由でネットワーク越しにshuvi-libをプロジェクトに取り込む方法です。

<script src="http://api.yuki540.com/shuvi-lib/v1/shuvi.lib.js"></script>

Usage

shuvi-libを使えば、YouTube IFrame Player APIをより簡単に操作することが可能です。

shuvi.lib.jsを取り込み、下記のようにパラメータを渡し、newすれば、すぐにプレイヤーの操作が可能になります。

let shuvi = new Shuvi({
  video_id : 'fQN2WC_Acpg',   // 動画ID
  id       : 'player',        // 要素のID
  width    : 500,             // 画面の幅
  height   : 300,             // 画面の高さ
  autoplay : ture,            // [option]自動再生(デフォルトはtrue)
  loop     : false            // [option]ループ(デフォルトはfalse)
})

npm経由の方は、requireを忘れずに。

const Shuvi = require('shuvi-lib')

Methods

shuvi-libは、できるだけシンプルでわかりやすいメソッド名にしています。

動画URLから動画IDの取得

video_id = getId(url)

  • [param]url: YouTubeの動画URL
  • [return]video_id: 動画ID

イベントリスナの追加

shuvi.on(event, fn)

  • [param]event: イベント名
  • [param]fn: コールバック関数

現在設定している動画IDの取得

shuvi.getVideoID()

  • [return]video_id: 動画ID

動画の変更

shuvi.change(video_id)

  • [param]video_id: 動画ID

再生

shuvi.play()

停止

shuvi.pause()

ループの有無

shuvi.loop(bool)

  • [param]bool: trueの場合、ループ有。falseの場合、ループ無。

デフォルトは、ループ無です。

再生位置の移動

shuvi.seek(per)

  • [param]per: 0~1の数値

動画の総時間

duration = shuvi.duration()

  • [return]duration: 動画の総時間

現在の再生時間

current = shuvi.current()

  • [return]current: 現在の再生時間

動画の読み込み状況

buffer = shuvi.buffer()

  • [return]buffer: 動画の読み込み具合(0~1)

音量の取得

volume = getVolume()

  • [return]volume: 0~1の値

音量の設定

shuvi.setVolume(volume)

  • [param]volume: 0~1の値

サイズの変更

shuvi.resize(width, height)

  • [param]width: 画面の幅
  • [param]height: 画面の高さ

Events

shuvi-libは、プレイヤーの動作ごと挙動をイベントとして呼び出されます。

  • load
    • 動画の起動読み込み終了時に呼び出されます。
  • error
    • 動画の読み込み・再生の失敗時に呼び出されます。
  • change
    • 動画の変更時に呼び出されます。
    • 初回の動画の時には、発火されません。
  • play
    • 動画再生時に呼び出されます。
  • pause
    • 動作停止時に呼び出されます。
  • seek
    • 動画の再生時間が変更されるたびに呼び出されます。
  • end
    • 動画の再生が終了時に呼び出されます。

Lisence

このライブラリは、MIT Lisenceのもとで公開されています。