-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding instructions for Vue.js 3 #137
Comments
@vsojo thank you for this. The Standalone H5P package essentially provides the logic to load the content, libraries and respective dependencies. After everything is loaded, we pass the control to H5P core player library (H5P.js) which handles the rest. I think that's is something which is not really clear at the moment in the docs. |
One can skip the second download of the H5P standalone zipped files by using something like {
"frameJs": "https://cdn.jsdelivr.net/npm/[email protected]/dist/main.bundle.min.js",
"frameCss":"https://cdn.jsdelivr.net/npm/[email protected]/dist/styles/h5p.min.css"
} other CDN hosted files should also work as well. |
Thanks, @murageyun. In my case, I am planning to use it for a standalone mobile app for teachers in developing countries, where data/signal may not be guaranteed; so I guess I better distribute all necessary files packaged within the application itself. Question: Do you mean I can load h5p-standalone from my local copy of |
Yes! You could achieve that by copying the |
Thanks! I did that and can load the
ERROR: The requested module 'assets/frame.bundle.js' does not provide an export named 'H5P' |
that won't work as we currently don't support it. I suggest copying the frameJs, frameCss, and the fonts from e.g. using cpx to copy everything in the node_modules/h5p-standalone folder except {
"postbuild": "cpx 'node_modules/h5p-standalone/dist/**/!(main.bundle.*)' 'dist/assets/h5p-standalone'"
} this will run atomatically after you run Thus in your H5P standalone player config, you could do something like: {
"frameJs": "/assets/h5p-standalone/main.bundle.min.js",
"frameCss":"/assets/h5p-standalone/styles/h5p.min.css"
} The assets might not be available during development if serving the app using {
"postdev": "cpx 'node_modules/h5p-standalone/dist/**/!(main.bundle.*)' 'dist/assets/h5p-standalone'"
} I am not well familiar with Vue and the output folder is just for demo purpose, so replace with most appropriate location. |
Any example for Previous state restoration? |
I kept getting all sorts of errors installing on Vue because I was getting confused with the documentation.
For posterity, and in the hope that it may help somebody someday, here's what I did to make it work in Vue 3, perhaps you guys want to add it into the instructions:
Instructions for Vue.js
Installing
h5p-standalone
npm install h5p-standalone
from the root folder of your project (where yourpackage.json
lives), or do the same withyarn add
if you're using yarn./public/
folder of your project, for example:/public/h5p/
(but this is entirely arbitrary as long as it's inside/public
). Note: The file namedh5p-standalone-X.Y.Z.zip
works; perhaps thesource-code
files also work (?).dist
folder up to the/public/h5p/
folder.readme
file now.dist
folder if you want, for example, from/public/h5p/dist
you can rename it to/public/h5p/h5p-standalone
.Making your H5P content files available
/public/h5p/contents/memory-baby-goats.h5p
.h5p
to.zip
.zip
.zip
and keep the decompressed folder.Now we're ready to put it all together.
Rendering an H5P file in your Vue template
template
, add a container for the H5P content:<div id="h5p-container"></div>
script
section, you have to import the library and create the object, but you also have to link to the public CSS and JS files:As noted in the code, the loading must occur inside
onMounted
because thediv
element doesn't exist before the component is mounted!Also, note that the locations
h5p/contents/
andh5p/h5p-standalone/
are arbitrary and match the example here, but you may have different paths (same with the baby goats, of course).The text was updated successfully, but these errors were encountered: