ZWPlayer Player - Download, Installation, and Usage Guide
1. HTML5 Installation
1.1 Download
Download link for the latest version v3.3.0: https://cdn.zwplayer.com/v3.3.0/zwplayer.zip
After downloading, unzip the file and upload the entire zwplayer folder to your website directory.
Note:
- Upload the entire
zwplayerdirectory; the directory name must bezwplayer. - All files contained in
zwplayerare static files. They must be placed in the web server’s public static resource directory (such aspublicorstatic), and must be accessible via HTTP/HTTPS without any access restrictions.
1.2 File Structure
zwplayer/ # Root directory of the zwplayer player
├── css/ # Style files and related resource files
├── plugins/ # Embedded plugins
├── widgets/ # Interface widgets
└── zwplayer.js # Main player file
1.3 Including the Player
Include zwplayer.js in the <head> tag of your HTML file. There are two ways to do this:
-
Local inclusion (assuming the
zwplayerfolder is located in the web root):<script type="text/javascript" charset="utf-8" src="/zwplayer/zwplayer.js"></script> -
CDN inclusion:
<script type="text/javascript" charset="utf-8" src="https://cdn.zwplayer.com/v3/zwplayer/zwplayer.js"></script>
Important Note:
- Unlike other players that require including multiple files, such as CSS and JS files,
zwplayeronly requires including the single filezwplayer.js. There is no need to manually include additional files, which simplifies integration and usage for developers. - The player will dynamically load related resources as needed. For example, when playing FLV video streams, the
zwplayerwill automatically load theflv.jscode file at runtime, thereby improving page load speed.
1.4 Usage
- Include the main
zwplayerfilezwplayer.js: As described above. - Create a player container: Add a
<div>in your HTML to serve as the player container. - Initialize the player: Create one or more player instances using the global
ZWPlayerclass.
Example Code
The following is the simplest usage example for zwplayer:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" charset="utf-8" src="https://cdn.zwplayer.com/v3/zwplayer/zwplayer.js"></script>
</head>
<body>
<div id="mse"></div>
<script type="text/javascript">
var info = {
playerElm: 'mse',
url: 'https://d2zihajmogu5jn.cloudfront.net/elephantsdream/ed_hd.mp4'
};
var player1 = new ZWPlayer(info);
</script>
</body>
</html>
Parameter Description
- playerElm: Abbreviation for player Element. The purpose of this parameter is to locate the player; provide a div element as the positioning element for the player. The player will dock within this element. The
playerElmparameter can be the ID of a div element, or it can directly accept a div element object (a DOM object obtained via functions likedocument.getElementByIdordocument.querySelector). - url: Represents the media URL to be played by the player, or a JavaScript object defining the media URL. Since
zwplayeris very powerful, there are many forms of writing for thisurlvalue. For details, please refer to Source URL parameter description.
Note:
- The
ZWPlayerinstance is a pure JavaScript object, not a DOM object, and cannot be directly passed to JS frameworks like jQuery or Zepto. - The
zwplayerobject has a few methods that allow developers to controlzwplayer. - You can create any number of
zwplayerobjects in the same H5 webpage. These objects are independent of each other and will not cause any conflicts regarding internal data references, etc.
2. Vue Project Installation
2.1 Vue 2.x Project
- Install the Vue 2 interface package
npm install zwplayer-vue2x --save
We have also created a demo project for the Vue 2 interface, which you can find in the following repositories: Example Repository Addresses:
- Gitee: https://gitee.com/chenfanyu/zwplayer-vue2x-demo
- GitHub: https://github.com/chenfanyu/zwplayer-vue2x-demo
2.2 Vue 3.x Project
- Install the Vue 3 interface package
npm install --save zwplayervue3
We have also created a demo project for the Vue 3 interface, which you can find in the following repositories: Example Repository Addresses:
- Gitee: https://gitee.com/chenfanyu/zwplayervue3-demo
- GitHub: https://github.com/chenfanyu/zwplayervue3-demo
2.3 Precautions
- Before installing the Vue interface package, please ensure that a
publicdirectory exists in your project. - After successful installation, the
zwplayercore library directory will be automatically generated under thepublicdirectory. - This directory must be built and published along with the project.