Forum Discussion
Embed code using javascript
Hello,
Has anyone created an embed code using javascript before? I think it's using the method described in the article link below. Unfortunately I cannot use the usual iframe embed code because when the published Storyline file is uploaded to our SAP based LMS it creates special characters. Those characters mean SAP will not upload the finished course package. I am publishing a scormed package to SAP LMS and js code created by Viostream video is:
<script src="//play.viostream.com/embed/nixx79jdue59er"></script> |
Seeking help with js code to create a separate .js file as described below.
Don't include <script type="text/javascript"> in your triggers.
If you'd like to include all your JavaScript functions in a separate JavaScript (.js) file, place your custom JavaScript file in the story_content folder of your published output, then add the following line of code to the story.html file before the closing </head> tag.
<script LANGUAGE="JavaScript1.2" SRC="/story_content/MyJavaScriptFunctions.js" TYPE="text/javascript"></script>
- Nathan_HilliardCommunity Member
So, were you trying to find a way to load a JS library through a JS trigger inside of SL, instead of hardcoding it into the project files? I wasn't quite sure of your goal.
If so, look at the trigger in the attached file. It loads your viostream library on slide timeline start. The library adds the following functions to the window object (e.g., window.videojs()).
You could add the script to the master slide and set a variable to make sure the trigger runs only once to load it once for your entire project, making it available on any slide.
- SamanthaKerr-87Community Member
Hello Nathan,
Thanks for responding to me. My preference was to use the usual video embed code (an iframe) but when I scorm and export the project to upload to our SAP based LMS the published output contains a bunch of special characters from the embed code that the LMS can't cope with. I would love to upgrade our LMS, but that is not an option. I did note that our video host provides both iframe codes and references to java script. <script src="//play.viostream.com/embed/nixx79jdue59er"></script>
I tried putting this into the embed code editor, but it does not work either.
So my question was how else can I use that code in the project? I was thinking perhaps I could create a .js video script, add it to the story-content folder and update the story.html file as they suggest in the help documentation.
- Nathan_HilliardCommunity Member
The script you mention appears to be the actual player rather than the video.
Do you normally just do an insert video in SL with your embed code? Are you able to share the the embed code for the video? When you say there are special characters in the published scorm output, how do you know, and can you share the modified embed?
Possibly you could insert a web object into SL instead of a video, and craft your own mini page inside the index.html that would load the player script and the video embed? It's difficult to speculate without something to test.