DEVELOPERS / QUICKSTART

Embed your first P2LRN course in a website

Load a sample course into Player using HTML and the CDN. Test it on your local HTTP server; learner identity and grades require a separate Host integration.

Before you begin

This walkthrough embeds Player in a website. Teachers creating lessons should follow the Studio authoring guide instead.

Create a test folder for the example package and your HTML file. Check that the course plays in the viewer before embedding it.

1. Download an example package

Save the example to a working folder. The rest of this guide assumes that the file is called scorm12-browser-demo.p2lrn.

2. Create an HTML page

Save this file as index.html in the same folder as the package. The script loads Player from the CDN and the <p2lrn-player> element opens the course from the same folder.

index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title>P2LRN</title>
  <script src="__P2LRN_PINNED_PLAYER_URL__" integrity="__P2LRN_PINNED_PLAYER_SRI__" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head>
<body>
  <p2lrn-player src="./scorm12-browser-demo.p2lrn"></p2lrn-player>
</body>
</html>

3. Open the folder in your editor and serve it over HTTP

Open the example folder in your usual text or code editor. So that the browser can load the package and its resources correctly, open the page from a local HTTP server instead of opening index.html directly using file://.

  1. Locate index.html and confirm that scorm12-browser-demo.p2lrn is in the same folder.
  2. Use your editor's preview or local server option, or any static HTTP server you prefer.
  3. Open the local address provided by that server in your browser, usually based on localhost or 127.0.0.1.

You do not need a specific editor or extension; the important thing is to serve the folder over HTTP.

4. Check the result

The page should display the quiz within the Player. If it appears, you have already checked the essential path: loading the component, opening a package and running its contents from a web application.

What have you integrated?

The Player has been loaded from CDN; the course remains a separate .p2lrn file. From here you can decide how you want to maintain that integration in your project.

5. Continue with the installation

The next step is Installation. The documentation first introduces CDN—the natural continuation of this example—and then NPM for projects that manage their dependencies through packages.

Common problems

The course does not open

Check that the package filename matches the src attribute and that both files are served from the same folder.

The page was opened as a local file

Use your local server's HTTP URL, not file://.

You need learner accounts and grades

This example only loads a course. For authenticated progress and grades, follow the Host and LMS integration guides.