{"_id":"59bba3e115d1e1002426165b","category":{"_id":"59bba3e115d1e10024261654","version":"59bba3e115d1e10024261652","project":"55e6dcb32d0d3021000daf70","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-04T12:01:11.730Z","from_sync":false,"order":1,"slug":"basics","title":"Basics"},"user":"55e6dc8a2d0d3021000daf6e","project":"55e6dcb32d0d3021000daf70","parentDoc":null,"version":{"_id":"59bba3e115d1e10024261652","project":"55e6dcb32d0d3021000daf70","__v":1,"createdAt":"2017-09-15T09:56:49.752Z","releaseDate":"2017-09-15T09:56:49.752Z","categories":["59bba3e115d1e10024261653","59bba3e115d1e10024261654","59bba3e115d1e10024261655","59bba3e115d1e10024261656","59bba3e115d1e10024261657"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-07T09:13:15.962Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Setting up afterglow is a pretty easy task. As afterglow is designed to do all the work, you won't have to do that much yourself.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 1 - include afterglow's Javascript file\"\n}\n[/block]\nThis is the first thing you should do. You must include afterglow's Javascript file into your HTML markup. The `<script>` tag can be placed within the document's `<head>` element or somewhere in the `<body>` element (preferably at the bottom, just above the closing `</body>` tag.\n\nHere is an example of script inclusion within the `<head>` element.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<!DOCTYPE html>\\n<html>\\n  <head>\\n    <!-- Lot's of meta stuff here -->\\n    <script src=\\\"//cdn.jsdelivr.net/npm/afterglowplayer:::at:::1.x\\\"></script>\\n  </head>\\n  <body>\\n    <!-- Some content here -->\\n  </body>\\n</html>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nThat's it, afterglow will now start working with any `<video>` elements it finds in the markup.\n\nIn this example, we used the CDN hosted version of afterglow, which will automatically be updated to the latest version if there are new releases. You could also download and self-host afterglow. Read more about this in the [self-hosting guide](doc:self-hosting-afterglow).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Step 2 - add video elements\"\n}\n[/block]\nAs soon as the script is included into the markup, afterglow will start looking for video elements having the class *'afterglow'*. These video elements will be initialized and converted into fully functional afterglow player instances.\n\nSo, all you've got to do now is to create `<video>` elements and include them into your markup.\n\nHere's a quick code sample for a basic valid `<video>` element.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<video class=\\\"afterglow\\\" id=\\\"myvideo\\\" width=\\\"1280\\\" height=\\\"720\\\" src=\\\"/path/to/myvideo.mp4\\\" /></video>\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nIf you want to know more about that `<video>` element, you can read some more about it here: [W3C Wiki](https://www.w3.org/wiki/HTML/Elements/video).\n\nMaybe you have noticed that we don't have to use the `<source>` element for a valid video element. This works only with a single video source, which is not recommended for optimum cross device/browser support. We have some information on this, [read more about multiple sources](doc:video-sources).\n\nYou might also have noticed that there are some attributes that we have added to the `<video>` element, like *class*, *id*, *width* and *height*. These attributes are very important. If you don't know why, you should read the [player parameters guide](doc:player-parameters).\n\nIf you do not want to use [responsive scaling](doc:responsive-scaling), you will have to disable it.","excerpt":"This page will tell you about how to setup afterglow.","slug":"basic-player-setup","type":"basic","title":"Basic player setup"}

Basic player setup

This page will tell you about how to setup afterglow.

Setting up afterglow is a pretty easy task. As afterglow is designed to do all the work, you won't have to do that much yourself. [block:api-header] { "type": "basic", "title": "Step 1 - include afterglow's Javascript file" } [/block] This is the first thing you should do. You must include afterglow's Javascript file into your HTML markup. The `<script>` tag can be placed within the document's `<head>` element or somewhere in the `<body>` element (preferably at the bottom, just above the closing `</body>` tag. Here is an example of script inclusion within the `<head>` element. [block:code] { "codes": [ { "code": "<!DOCTYPE html>\n<html>\n <head>\n <!-- Lot's of meta stuff here -->\n <script src=\"//cdn.jsdelivr.net/npm/afterglowplayer@1.x\"></script>\n </head>\n <body>\n <!-- Some content here -->\n </body>\n</html>", "language": "html" } ] } [/block] That's it, afterglow will now start working with any `<video>` elements it finds in the markup. In this example, we used the CDN hosted version of afterglow, which will automatically be updated to the latest version if there are new releases. You could also download and self-host afterglow. Read more about this in the [self-hosting guide](doc:self-hosting-afterglow). [block:api-header] { "type": "basic", "title": "Step 2 - add video elements" } [/block] As soon as the script is included into the markup, afterglow will start looking for video elements having the class *'afterglow'*. These video elements will be initialized and converted into fully functional afterglow player instances. So, all you've got to do now is to create `<video>` elements and include them into your markup. Here's a quick code sample for a basic valid `<video>` element. [block:code] { "codes": [ { "code": "<video class=\"afterglow\" id=\"myvideo\" width=\"1280\" height=\"720\" src=\"/path/to/myvideo.mp4\" /></video>", "language": "html" } ] } [/block] If you want to know more about that `<video>` element, you can read some more about it here: [W3C Wiki](https://www.w3.org/wiki/HTML/Elements/video). Maybe you have noticed that we don't have to use the `<source>` element for a valid video element. This works only with a single video source, which is not recommended for optimum cross device/browser support. We have some information on this, [read more about multiple sources](doc:video-sources). You might also have noticed that there are some attributes that we have added to the `<video>` element, like *class*, *id*, *width* and *height*. These attributes are very important. If you don't know why, you should read the [player parameters guide](doc:player-parameters). If you do not want to use [responsive scaling](doc:responsive-scaling), you will have to disable it.