VideoJs formatTime is undefined - video.js

I'm using videojs and want to use the function as per docs formatTime, but I get as result undefined
I don't use npm package of videojs, instead, I have referenced the minified version 7.6.5 direct in my code.
Is there any extra file I should reference in this case?

It's a method on videojs, not the player instance:
videojs.formatTime(100);
> "1:40"

Related

How to use the SDK without the dependency on a main video

I am trying to put an ad without the need to put a video,
I tried to remove the video in the function and in the html view, but I get this error:
TypeError: Cannot read properties of undefined (reading 'init')
Code
adsManager.init(640, 360, google.ima.ViewMode.NORMAL);

Can't import Ink interpreter with Javascript interpreter with Vue.js

I need to make a Vue.js site with a JavaScript Ink interpreter. The only one that seems to be production-ready is Ink.js. There are two ways to import it. One is in its TypeScript format, but my Vue setup does not use TypeScript. I could add it, maybe, although I'm not sure I want to. If I import the TypeScript libraries from Yarn, no matter which object I import, it shows up with a value of undefined in my code.
Then there is a pure es5 script available, that seems to be a transpiled version of the first one, but when I try to import that one, I get this error, I think from Babel:
Uncaught SyntaxError: Unexpected token '!'
cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/Ink.vue?vue&type=script&lang=js&:39 Uncaught SyntaxError: Unexpected token '!'
at Object../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/Ink.vue?vue&type=script&lang=js& (app.js:962)
My guess is that Babel is set up for es6 or es7 and the pure is5 file brings up some unexpected syntax. I tried to change babel.config.js, but I've found no option that's kept Vue.js from complaining. What am I doing wrong? 
After many failed attempts, I went around the problem in the following way: I imported the Story object directly from the library:
import { Story } from '../../node_modules/inkjs/engine/Story';
// ...
let story = new Story(storyText);
I know it's not what the documentation recommends, but it works. And it seems everything else that needs to be imported is, because when I try to read story.currentChoices I get an array of Choice objects that are in turn perfectly readable.
So this works for me. If anyone else runs into this problem, I'm not saying it's the right solution, I'm just saying that's what I finally ended up doing.

How to add JS frameworks to use in the backend of SailsJS?

I want to add Underscore JS to be used in the BackEnd so I can call _. functions from my Controllers. How do I do that?
You don't need to do anything.
Sails loads LoDash by default.
It is already assigned to "_".
So unless you need some very specific incompatibility between LoDash and underscore.... of which i don't know of.....your done.
First, you have to install the library you want to add with npm install --save <libraryName>.
Then, on top of your controller, before module.exports = ..., require this library:
var libraryName = require('<libraryName>');
That's it.
In case of Underscore.js it will be:
npm install --save underscore
then
var _ = require('underscore');
on top of your controller. After that you'll be able to use _.-functions anywhere in this file.
UPDATE
The answer by InternalFX makes perfect sense too. Sails.js indeed globalizes Lodash via _, and pretty much all the functionality of Underscore Lodash implements too, so in this case, that's right, you don't even have to do anything.

How do I tell a Dojo custom build about external libraries?

In my Dojo build, I'm pulling in some third party libraries.
As I go through the build process, I'm getting errors due to ReferenceErrors.
This is fine. This makes sense.
However, I'd like to tell the Dojo build process about the things that are being referenced. In essence, this would be akin to passing externs to the Closure Compliler.
Thus, my question: How do I tell the Dojo build process about references that it cannot infer from my code base?
This is using Dojo 1.8
I just ran into this myself. Now I'm assuming that the ReferenceErrors you referred to are for browser objects like navigator, window, document, and the like. If so, then this is a problem introduced by the Dojo build process itself, because the build is performed by dojo.js running inside of Rhino where browser global objects are not defined. It's a dojo/Rhino error, not a closure compiler error, so there's nothing you can pass to closure to change this. For example, a script like
(function(){
window.alert("hello");
})();
will break your dojo build if it is included in a dojo layer. When the dojo AMD loader resolves the dependency of a script like the above, it will run the body of the function, resulting in a ReferenceError because window does not exist in Rhino.
To get around this, wrap the script as an AMD module
define([], function(){
window.alert("hello");
});
and then the function body will NOT be executed by the AMD loader during dojo build.

is Adobe AIR's openWithDefaultApplication() not available in the AJAX SDK?

The only documentation of Adobe AIR's openWithDefaultApplication() function I can find is a tutorial for it in the Flex SDK. Is Flex required to use this function?
Calling it via JavaScript results in:
TypeError: Value undefined does not allow function calls.
The code I'm using:
var poster = air.File.applicationDirectory.resolvePath('posters/CR-1/CR-1.pps');
air.trace(poster); // [object File]
poster.openWithDefaultApplication();
The application file is likely set to....
<application xmlns="http://ns.adobe.com/air/application/1.5">
You must change it to
<application xmlns="http://ns.adobe.com/air/application/2.0">
for the 2.0 + functionality to work....