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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rplayer/ads

v0.6.0

Published

rplayer player ad plugin

Downloads

3

Readme

RPlayerAds

npm version

RPlayer 广告插件

安装

npm i -S @rplayer/ads

使用

import RPlayer from 'rplayer'
import RPlayerAds from '@rplayer/ads'

const player = new RPlayer({
  video: {
    src: 'http://upload.wikimedia.org/wikipedia/commons/transcoded/c/c0/Big_Buck_Bunny_4K.webm/Big_Buck_Bunny_4K.webm.480p.vp9.webm',
    crossOrigin: 'anonymous'
  },
  settings: [
    { label: '自动播放' },
    { label: '画质', options: [{ label: '720p' }] },
  ],
  subtitle: {
    captions: [{
      label: 'English',
      src: 'http://127.0.0.1:8001/friday.vtt'
    },{
      label: '中文',
      src: 'http://127.0.0.1:8001/friday-zh.vtt'
    }]
  }
})

const ads = new RPlayerAds({
  liner: [
    {src: 'https://interactive-examples.mdn.mozilla.net/media/examples/friday.mp4', duration: 5},
    {src: 'https://interactive-examples.mdn.mozilla.net/media/examples/friday.mp4', playWait: 10, duration: 5},
  ],
  nonLiner: [
    {
      imgSrc: 'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2534506313,1688529724&fm=26&gp=0.jpg',
      total: 3,
    }
  ]
})

player.use(ads)

player.mount()

配置

interface AdsOpts {
  liner?: LinerAdsItem[]; // 视频广告
  nonLiner?: NonLinerAdsItem[]; // 弹框广告
  onError?: (
    item: LinerAdsItem | NonLinerAdsItem,
    timeLeft?: number // 广告的剩余时间
  ) => boolean | void; // 出错时调用,返回 true 将跳过这个视频
  linerTimeout?: (items: LinerAdsItem[]) => boolean | void; // 参数是剩余的视频,广告剩余时间为 0 时,但是广告并没有播放完毕,返回 true 将播放正片
  enhanceVideo?: (video: HTMLVideoElement) => any; // 对广告 video 元素进行设置
  adBadge?: boolean; // 是否显示 广告 标识
}

interface AdsItem<T> {
  jumpTo?: string; // 点击广告时,跳转的链接
  onClick: (item: T) => any; // 当点击广告时
  [key: string]: any;
}

interface LinerAdsItem extends AdsItem<LinerAdsItem> {
  src: string;
  playAt?: number; // 在哪个时间点播放
  playWait?: number; // 正片播放多久 播放该广告 
  duration?: number; // 广告的时长
}

interface NonLinerAdsItem extends AdsItem<NonLinerAdsItem> {
  imgSrc?: string; // 图片的 src
  content?: string | Element; // 或者自定义广告元素
  showed?: number; // 显示了几次
  total?: number; // 一共显示几次
}