Video Embed API

Use your own domain for MegaPlay embeds. Open a local stream URL from this domain and the page will load the matching MegaPlay player behind it.

Usage

Embedded Domain: https://animeplay.cfd/

Anikoto / legacy HiAnime: https://animeplay.cfd/stream/s-2/{aniwatch-ep-id}/{language}

MAL: https://animeplay.cfd/stream/mal/{mal-id}/{ep-num}/{language}

AniList: https://animeplay.cfd/stream/ani/{anilist-id}/{ep-num}/{language}

Parameters

RouteParametersExample
/stream/s-2 {aniwatch-ep-id}, {language} https://animeplay.cfd/stream/s-2/2343/sub
/stream/mal {mal-id}, {ep-num}, {language} https://animeplay.cfd/stream/mal/21/5/dub
/stream/ani {anilist-id}, {ep-num}, {language} https://animeplay.cfd/stream/ani/1234/6/sub

Valid language values are sub and dub.

Embed Example

<iframe
  src="https://animeplay.cfd/stream/s-2/2343/sub"
  width="100%"
  height="100%"
  frameborder="0"
  allow="autoplay; fullscreen; picture-in-picture"
  allowfullscreen></iframe>

Player Events

The player sends events with postMessage. This wrapper forwards MegaPlay messages to your outer website unchanged, so you can listen for auto-next and watch-time tracking.

window.addEventListener("message", function (event) {
  let data = event.data;

  if (typeof data === "string") {
    try {
      data = JSON.parse(data);
    } catch (e) {
      return;
    }
  }

  if (data.event === "complete") {
    // auto-next episode
  }

  if (data.event === "time") {
    // progress updates
  }

  if (data.type === "watching-log") {
    // watch time logging
  }
});

Common Event Data

{
  event: "time",
  time: number,
  duration: number,
  percent: number
}

{
  type: "watching-log",
  currentTime: number,
  duration: number
}