@donkeyclip/motorcortex-player

中文文档
2.17.0发布于 2026/05/04MITESM + CJS近 30 天下载 7680

Player plugin for MotorCortex

原始使用文档
文档目录15 节
  1. Demo
  2. Installation
  3. Importing
  4. Options
  5. Methods
  6. Themes
  7. transparent
  8. blue
  9. green
  10. yellow
  11. dark
  12. darkGold
  13. whiteGold
  14. custom
  15. DonkeyClip QueryParams

MotorCortex-Player

Table of Contents

Demo

Check it out here

Intro / Features

MotorCortex Player is a video-like player specially designed for MotorCortex Clips. Among other functionality, the player allows the user to play/pause and seek a Clip, control the master volume and the playback speed and more.

What does our player include?

Player Controls Image

  1. Play/pause button
  2. Master volume
  3. Time: the time passed on the Clip's playback/total clip time
  4. Loop: Click on this button if you want to set a loop on Clip's playback. Two grey anchor points will appear on the timeline from where you can define the loop boundaries.
  5. Options: Click to open the options panel
  6. Full Screen: Clip to go fullscreen
  7. Pointer Events: Enabling "pointer-events" will allow your mouse to access the contents of the Clip. Otherwise, all mouse (pointer) events are disabled on the Clip's content
  8. Show volume: shows or hides the master volume control (#2)
  9. Speed: click to open the speed change control
  10. Player's background-color
  11. The actual motorcortex clip

Getting Started

Installation

$ npm install --save @donkeyclip/motorcortex-player
# OR
$ yarn add @donkeyclip/motorcortex-player

Importing

import MCPlayer from "@donkeyclip/motorcortex-player";

Creating Player

The player can be used with any MotorCortex Clip. Here is an example with the minimum possible configuration:

const player = new MCPlayer({ clip: MyClip });

Options

Except for the (mandatory) clip option that should be passed on the player on instantiation there is a list of other supported options:

OptionDefault valueDescription
clip-The MotorCortex Clip object that the Player will control
showVolumefalseShow or hide the master volume control (#2)
hostnullThe Player by default "wraps" the Clip and seats at the bottom of its container taking advantage of the full width of it. In case you want the Player to get rendered on a different host (element) you can pass this element here
buttons{ loop: true, fullScreen: true, settings: true }An object via which you can select which of the three buttons (#4: Loop via the key "loop", #5: Settings via the key "settings", #6: Full Screen via the key "fullScreen"). Enable and disable the buttons by setting their corresponding keys to true or false, accordingly
timeFormatssThis option allows you to set the time units on the Time (#3) of the Player. The default is ss, which means the Time will be presented in the form: < elapsed seconds >/< total seconds >. In the case you want a representation in the form: ms/ms you can set this option to "ms"
theme"transparent"Here you can pick one of the available themes of the player. The available themes are: "transparent", "blue", "yellow", "green","whiteGold","darkGold","dark" and "default"
themeCSS-Define your own theme using this property. Checkout how to define custom themes
volume1With this option you can define the volume value. Acceptable values are any number between or equal to 0 and 1
speed1A property from witch you can select the execution speed. Any value positive or negative is acceptable
loopfalseA boolean indicator whether the clip will initalize with the loop option on
autoPlayfalseWith this option you can auto-start the clip when the loading is complete
controlstrueThis option allows you to select if the player controls will be visible, therefore availble to the users. You cannot play or pause the clip by click events when this option is disabled. Scroll events are available if the player's type is set to "scroller"
scaleToFittrueA property to define if the clip will be auto-scaled to fit to its' host element or not
overflow"hidden"A property to define if the you want elements outside the clip borders to be visible or not. Any css overflow values are acceptable
outlineunsetA property to define the border style of your clip. This can be useful on edit time. Any css border value is accepted
visibleunsetA property to define if you want your clip to be above the player controls. Accepted values are undefined, "always"
pointerEventstrueThis options adds a transparent div element on top of the clip in order to prevent user events (eg selection) on the clip element. When enabled, any click event on the clip triggers the play or pause event
backgroundColor'black'A css color value to define the players background
speedValues[ -1, 0.5, 1, 2]An array of number values to provide as supported options on the speed setting panel. This option will not prevent the user to change the clip speed programmatically to another value not provided in the speedValues property
mutedfalseA Boolean property to define if the clip will be muted on start
currentScript(Interests donkeyclip developers) If the clip will be loaded from a script with an external source where the player will be included, you can provide the script element refernce and use all the available control properties as data-* attributes of the script (eg currentScript=document.currentScript)
millisecond0The millisecond from witch the clip will start
thumbnail-A thumbnail image url to display in idle state
thumbnailColor-A thumbnail background color to display in idle state
type"default"You can select of the types "scroller" or "default". If you don't define this property the default player is active
scrollAnimationfalseIf you set this property to true you can add animation to you scroll by extending the time of scroll
maxScrollStorage50You can store scroll events to extend the scroll experience. This property works best with scrollAnimation set to true and it takes an interger value greater than zero
sections-You can define sections as an array of milliseconds when you want to ankor the scroll events. (eg [0,1000,2000,3000]). Note that the zero(start) and clip's duration(end) are needed as values.

Methods

NameArgumentsDescription
onMillisecondChangefunction(millisecond)A function callback to be called after every millisecond change of the clip
goToMillisecondfunction(millisecond, clipCommands = {})A function from witch you can create a journey over the clips timeline. The clipCommands accepts the properties 'before' and 'after', from where you can for example pause the clip before the journey and 'play' it after (eg clipCommands={before:'pause',after:'play'}
createLoopfunction(msStart, msEnd)With this method your can define a loop with boundaries. The loop option must be set to true for this to work
changeSettingsfunction(newOptions)This function allows you to manipulate the player options after the initialization. All the options provided in the 'Options' section can be used here
changeInitParamsthe clips initparams objectYou can change any initial parameters of the clip by providing new values through this method. Any parameters that won't be defined here will remain the same as the previous state of initial parameters.
enterFullScreen-You can enter fullscreen mode with code
exitFullScreen-You can exit fullscreen mode with code
//example using player methods
import MClayer from "@donkeyclip/motorcortex-player";
const player = new MCPlayer({
  clip: MyClip,
  onMillisecondChange: (ms) => console.log("There goes another millisecond. I am gonna live forever"),
});
player.changeSettings({ controls: false, speed: "2", loop: true });
player.createLoop(1000, 3000);
player.changeInitParams({ text: "hello world" });

Themes

transparent

Player Controls

blue

Player Controls

green

Player Controls

yellow

Player Controls

dark

Player Controls

darkGold

Player Controls

whiteGold

Player Controls

custom

All you have to do is define the following css text within the property themeCSS and use the name in the property theme of player options

const player = new MCPlayer({
  clip: MyClip,
  themeCSS: `
  .--mc-player.theme-test {
    --activeColor: 136, 136, 500;
    --defaultColor: 136, 136, 136;
    --backgroundColor: 29, 31, 37, 1;
    --loopBarColor: rgba(var(--activeColor), 0.2);
    --grad-display: none;
  }`,
  theme: "theme-test",
});

DonkeyClip QueryParams

All player options can be exploited by donkeyclips through query parameters. Any option of type boolean can be enabled without the need of the value "true". To disable options that are enabled by default you have to set the value the "false" for example:

https://api.donkeyclip.com/v1/embed/xxxxxxxxxx?controls=false&autoPlay&scaleToFit&theme=yellow&speed=2

For development purposes you can use the following query parameters to test different MotorCortex, Player, and Bundler versions:

  • mcversion
  • playerversion
  • bundlerversion

For example: https://api.donkeyclip.com/v1/embed/xxxxxxxxxx?controls&mcversion=7.4.0&playerversion=2.5.0&bundlerversion=7.0.1

Contributing

In general, we follow the "fork-and-pull" Git workflow, so if you want to submit patches and additions you should follow the next steps:

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

Sponsored by

版本与发布记录

@donkeyclip/motorcortex-player 共发布 89 个版本,首次发布于 2021/09/23;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.17.0latest2026/05/046 个月前
2.16.12026/05/016 个月前
2.16.02026/04/306 个月前
2.15.182025/10/231.1 年前
2.15.172025/10/231.1 年前
2.15.142025/08/011.3 年前

关于 @donkeyclip/motorcortex-player 的常见问题

@donkeyclip/motorcortex-player 是什么?

Player plugin for MotorCortex

如何安装 @donkeyclip/motorcortex-player?

在项目目录运行 npm install @donkeyclip/motorcortex-player,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@donkeyclip/motorcortex(>=9.19.0)、@donkeyclip/motorcortex-player-lite(>=1.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@donkeyclip/motorcortex-player 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/donkeyclip__motorcortex-player 是否存在。

@donkeyclip/motorcortex-player 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@donkeyclip/motorcortex-player 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@donkeyclip/motorcortex-player 可以商用吗?

@donkeyclip/motorcortex-player 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@donkeyclip/motorcortex-player 的下载量有多少?

根据 npm 官方下载统计,@donkeyclip/motorcortex-player 在 2026/10/13 – 2026/11/11 这 30 天内被下载 7,680 次,日均约 256 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@donkeyclip/motorcortex-player 还在维护吗?

最新版本 2.17.0 发布于 2026/05/04(6 个月前);至今共发布 89 个版本,其中过去 12 个月发布了 3 个;首次发布于 2021/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。