Clappr is an extensible web media player

Clappr is an extensible web media player

2022-10-10 0 1,599
Resource Number 45020 Last Updated 2025-02-24
¥ 0HKD Upgrade VIP
Download Now Matters needing attention
Can't download? Please contact customer service to submit a link error!
Value-added Service: Installation Guide Environment Configuration Secondary Development Template Modification Source Code Installation

The Clappr recommended in this issue is an extensible web media player.

Clappr is an extensible web media player插图

Clappr is an extensible web media player. Your architecture is primarily projected into plug-ins, which are designed to add low coupling to your project and make it easy to add unlimited functionality.

Clappr uses HTMLVideoElement by default to guarantee support for many platforms. You can extend the default HTML5 playback or playback interface to create a new media support, just like a plugin!

HTMLVideoElement Address:
https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement

Usage of Clappr

Tags via script:

Add the following script to your HTML:

< head> 
< script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@clappr/player@latest/dist/clappr.min.js"> < /script> 
< /head> 

Now, create the player:

<body>
  <div id="player"></div>
  <script>
    var player = new Clappr.Player({source: "http://your.video/here.mp4", parentId: "#player"});
  </script>
</body>

Through the npm module:

The project is available on npm at
https://www.npmjs.com/package/@clappr/core

yarn install @clappr/core --save-dev

You should specify the base URL baseUrl where the asset is located with the following option:

  var player = new Clappr.Player({
source: "http://your.video/here.mp4",
baseUrl: "http://example.com/assets/clappr"
}); 

In the above case, Clappr will expect all assets (in the dist folder) to be available in the”
Visit http://example.com/assets/clappr-core “. You need baseUrl to arrange the assets to be located during the build process.

Install for webpack:

By default, webpack will look at this main field package.json and use the build version of the project. If that’s what you want, then there’s nothing left for you to do.

If you want to build Clappr itself into your project during the build process, add the following to your webpack configuration:

resolve: {
alias: { Clappr: '@clappr/core/src/main.js' },
root:  [path.resolve(__dirname,  'node_modules/@clappr/core/src')],
extensions:  ['', '.js'],
}

API documentation

player.attachTo(element)

You can use this method to attach the player to a given element. You don’t need to do this when parentId is specified during the instantiation of the player that passes the parameter.

player.play()

Play the current source.

player.pause()

Pause the current source.

player.stop()

Stop the current source.

player.mute()

Mute the current source.

player.unmute()

Unmute the current source.

player.seek(value)

Find the current video (source). For example, player.seek(120) will search until the 120th second (2 minutes) of the current video.

player.seekPercentage(value)

Find the current video (source). For example, player.seek(50) will look for the middle of the current video.

player.isPlaying()

true Returns if the current source is playing, otherwise false.

player.getPlugin(pluginName)

Returns the plug-in instance. Example:

var strings = player.getPlugin('strings'); 

This method searches the Core and Container plug-ins by name and returns the first one found.

player.getCurrentTime()

Returns the current time in seconds of the current source.

player.getDuration()

Returns the duration of the current source in seconds.

player.resize(size)

Resize the current player canvas. The size argument should be width, a text object with heightand. Example:

player.resize({height:  360, width: 640}); 

player.destroy()

Destroy current player and remove it from DOM.

player.load(source)

Load new source.

player.configure(options)

allows the player to be configured after it has been created.

Clappr configuration

All parameters listed below should be added to the Clappr.Player object instantiated or via player.configure.

Example:

var player = new Clappr.Player({
source: "http://your.video/here.mp4",
parameter1: "value1",
parameter2: "value2",
});

// or

player.configure({
parameter3: "value3",
parameter4: "value4",
})

Note that some options through configure are not applied immediately. In this case, these options will be applied in the next video.

Clappr plug-in

Media control

A plugin that renders the interface on the video container and adds the possibility to control playback operations (play, pause, stop).

Click Pause

Adds the possibility to switch between play/ play states by clicking on a container element.

var player = new Clappr.Player({
source: "http://your.video/here.mp4",
// Optionally,  send a payload upon the container's pausing with the `onClickPayload` parameter
clickToPauseConfig: {
onClickPayload: { any:  'any' } // sends the payload to container when  clicked
}); 

Hidden subtitles

Adds the possibility of custom subtitle labels and titles.

var player = new Clappr.Player({
  source: "http://your.video/here.mp4",
  closedCaptionsConfig: {
    title: 'Subtitles', // default is none
    ariaLabel: 'Closed Captions', // Default is 'cc-button'
    labelCallback: function (track) { return track.name }, // track is an object with id, name and track properties (track is TextTrack object)
  },
});

Poster

Define the poster image by adding the poster option to the Clappr player. It appears after the video is embedded, disappears during playback, and returns when the user stops the video. For audio broadcasts, the poster remains visible while playing.

var player = new Clappr.Player({
source: "http://your.video/here.mp4",
poster: "http://url/img.png"
}); 

Find time

Notifies the current time when the mouse hovers over the media control search bar.

var player = new Clappr.Player({
source: "http://your.video/here.mp4",
// Only for live stream with DVR
actualLiveTime:  true,  // default is false
// Meant to be used with actualLiveTime
actualLiveServerTime:   "2015/11/26 06:01:03" // default is current date
}); 

Watermark

Add a watermark to the video. Place the watermark option on your embed parameter to automatically add a watermark to your video. Select the corner position by defining the Position option. The positions can be bottom-left, bottom-right, and top-left. top-right To define the URL to open when you click the watermark, use watermarkLinkoption. If watermarkLink does not define parameters, the watermark is not clickable.

var player = new Clappr.Player({
source: "http://your.video/here.mp4",
watermark: "http://url/img.png",
position: 'top-right',
watermarkLink: "http://example.net/"
}); 

—END—

资源下载此资源为免费资源立即下载
Telegram:@John_Software

Disclaimer: This article is published by a third party and represents the views of the author only and has nothing to do with this website. This site does not make any guarantee or commitment to the authenticity, completeness and timeliness of this article and all or part of its content, please readers for reference only, and please verify the relevant content. The publication or republication of articles by this website for the purpose of conveying more information does not mean that it endorses its views or confirms its description, nor does it mean that this website is responsible for its authenticity.

Ictcoder Free Source Code Clappr is an extensible web media player https://ictcoder.com/clappr-is-an-extensible-web-media-player/

Share free open-source source code

Q&A
  • 1. Automatic: After making an online payment, click the (Download) link to download the source code; 2. Manual: Contact the seller or the official to check if the template is consistent. Then, place an order and make payment online. The seller ships the goods, and both parties inspect and confirm that there are no issues. ICTcoder will then settle the payment for the seller. Note: Please ensure to place your order and make payment through ICTcoder. If you do not place your order and make payment through ICTcoder, and the seller sends fake source code or encounters any issues, ICTcoder will not assist in resolving them, nor can we guarantee your funds!
View details
  • 1. Default transaction cycle for source code: The seller manually ships the goods within 1-3 days. The amount paid by the user will be held in escrow by ICTcoder until 7 days after the transaction is completed and both parties confirm that there are no issues. ICTcoder will then settle with the seller. In case of any disputes, ICTcoder will have staff to assist in handling until the dispute is resolved or a refund is made! If the buyer places an order and makes payment not through ICTcoder, any issues and disputes have nothing to do with ICTcoder, and ICTcoder will not be responsible for any liabilities!
View details
  • 1. ICTcoder will permanently archive the transaction process between both parties and snapshots of the traded goods to ensure the authenticity, validity, and security of the transaction! 2. ICTcoder cannot guarantee services such as "permanent package updates" and "permanent technical support" after the merchant's commitment. Buyers are advised to identify these services on their own. If necessary, they can contact ICTcoder for assistance; 3. When both website demonstration and image demonstration exist in the source code, and the text descriptions of the website and images are inconsistent, the text description of the image shall prevail as the basis for dispute resolution (excluding special statements or agreements); 4. If there is no statement such as "no legal basis for refund" or similar content, any indication on the product that "once sold, no refunds will be supported" or other similar declarations shall be deemed invalid; 5. Before the buyer places an order and makes payment, the transaction details agreed upon by both parties via WhatsApp or email can also serve as the basis for dispute resolution (in case of any inconsistency between the agreement and the description of the conflict, the agreement shall prevail); 6. Since chat records and email records can serve as the basis for dispute resolution, both parties should only communicate with each other through the contact information left on the system when contacting each other, in order to prevent the other party from denying their own commitments. 7. Although the probability of disputes is low, it is essential to retain important information such as chat records, text messages, and email records, in case a dispute arises, so that ICTcoder can intervene quickly.
View details
  • 1. As a third-party intermediary platform, ICTcoder solely protects transaction security and the rights and interests of both buyers and sellers based on the transaction contract (product description, agreed content before the transaction); 2. For online trading projects not on the ICTcoder platform, any consequences are unrelated to this platform; regardless of the reason why the seller requests an offline transaction, please contact the administrator to report.
View details

Related Source code

ICTcoder Customer Service

24-hour online professional services