This document describes current methods of implementing Danmaku on the Web, and proposes a Web API to easily enable Danmaku in Web browsers.
This is still a work in progress. The proposal is being incubated in the W3C Bullet Chatting Community Group.
This document uses the following terms:
Currently, Web developers mainly use Canvas or CSS to implement Bullet Chatting.
font
), color (fillStyle
), alpha (globalAlpha
) and so on using the properties. For example:clearRect
method to erase the canvas, calculate the position of the bullet chat in the next frame, and draw the bullet chat in the new position. For example:div
element, i.e., <div>danmaku</div>
.font
), color (color
), opacity (opacity
) and so on using the properties.transform
and transition
:
transform
property of the bullet chatting element to the current position and set the transition
duration to 0 to fix the bullet chatting at the current position. For example:The performance is better when used with WebGL and a large number of bullet chatting text can be displayed at the same time.
Not flexible. It is cumbersome to display bullet chat that contains both text and images, and to pause the animation of one of the moving bullet chats. Moreover, resolution issue needs to be addressed on mobile devices.
Simple and flexible. Developers can style the bullet chat through the DOM, and supports the combination of images and text. The user can pause a particular bullet chat of interest.
Huge collections of DOM nodes will be generated when the there are many bullet chats. It will consume more memory and make the page unresponsive. Moreover, to manipulate the bullet chatting such as making the bullet chat disappear, the corresponding DOM node needs to be removed.
The content of this section is still under discussion in the Media and Entertainment Interest Group. If you find any issue, or have any correction or question, feel free to raise a GitHub issue or send an email to public-web-and-tv@w3.org.
Bullet Chatting uses new elements such as
bulletchatlist
and bulletchat
. These elements are not used as children of the media elements audio
and video
. From the Scenarios section, we can see that the usage of bullet chatting is not limited to those media elements like video. In scenarios like Web page interaction or interactive wall, bullet chatting is independent of any media element.
This specification describes how the bullet chatting itself is rendered, not including the external bullet chatting list. Since bullet chatting does not depend on video
, there is no requirement for a bullet chatting list with timestamps. In a common on-demand video bullet chatting scenario, there is often a list of bullet chatting similar to the time-aligned data in [[webvtt1]], which requires the developer to add bulletchat
based on the time offset of the video.
bulletchatlist
is a block-level element, and bulletchat
is an inline element. The content permitted as children and descendants of the bulletchat
element include: text, images, and hyperlinks.
scroll
reverse
and top
Bullet Chatting display
area is calculated from the top of bulletchatlist, the bottom
Bullet Chatting
display area is calculated from the bottom of bulletchatlistfalse
if the display does not show the Bullet Chatting beyond the display
area; true
if the Bullet Chatting will be displayed overlapping the display area.
mode
: Defines the type of Bullet Chatting, value is one of the folloing: scroll
, top
,bottom
and reverse
.
scroll
The default value indicates a scroll bullet chat. The bullet chatting scrolls
from left to right, and the scrolling time is controlled by the CSS
property bulletchat-duration
. Display time rule: bulletchat
the leftmost element
into the bulletchatlist
element area to the display bulletchat
element from the
rightmost bulletchatlist
element of the display region disappears time consumed.
top
indicates the top bullet chatting.
bottom
indicates the bottom bullet chatting.
reverse
represents a reverse scrolling bullet chatting. The bullet chatting will scroll from
right to left, and the scrolling time is scroll
similar.
bulletchatstart
: Triggered when the Bullet Chatting animation starts.bulletchatend
: Triggered when the Bullet Chatting animation ends.bulletchatcancel
: Trigger when the Bullet Chatting is terminated unexpectedly, such as the
Bullet Chatting is removed or hidden, or because the display area is not displayed.bulletchat-play-state
: running | paused, defines the state of the Bullet Chatting as running
or paused, and can be inherited.bulletchat-duration
: <time>, in seconds (s) or milliseconds (ms), defines the speed of
the Bullet Chatting, which can be inherited.bulletchat-play-state
: running | paused, which defines the state of the Bullet Chatting as
running or paused, which can be inherited.bulletchat-duration
: <time>, in seconds (s) or milliseconds (ms), defines the speed of
the Bullet Chatting, which can be inherited.bulletchat-delay
: <time>, in seconds (s) or milliseconds (ms), defines when the Bullet
Chatting animation begins, defining a negative value allows a Bullet Chatting to start moving from the
middle.