ffissore / presentz.js

A js library to show synchronized video and slides presentations, powering presentz.org
http://presentz.org/
GNU Lesser General Public License v3.0
143 stars 20 forks source link

Examples for accessing youtube and slideshare details #19

Closed kracekumar closed 11 years ago

kracekumar commented 11 years ago

All the examples in directory are for auto changing slides w.r.t video, can you show an example how to use get current youtube video timing and current slide no.

ffissore commented 11 years ago

timing is driven by slides. to split a video while showing the same slide, you have to duplicate that slide with a different timing

kracekumar commented 11 years ago

If a video is currently running I would like to get the current time e.g 1.30. So I tried

presentz = new Presentz(".video169", $('.video169').width() + "x" + $('.video169').height(), ".video43", $('.video43').width() + "x" + $(".video43").height());
presentz.Youtube(presentz, ".video169", $('.video169').width(), $('.video169').height()) 
//also tried
presentz.Youtube(this, ".video169", $('.video169').width(), $('.video169').height())

TypeError: Object #<Object> has no method 'newElementName'

My main motive is to get current time of playing youttube video. Couldn't find any comments in the source code.

Edit:

presentz.availableVideoPlugins is undefined.

ffissore commented 11 years ago

Sorry, source code is lacking proper documentation. To get the current time, you need to call presentz.presentation.chapters[presentz.currentChapterIndex].video._plugin.currentTime() I should add a getCurrentTime() method to the presentz obj.

kracekumar commented 11 years ago

Seems currentTime is trying to access undefined ?

Uncaught TypeError: Cannot read property 'getCurrentTime' of undefined presentz-1.2.0.min.js:19
t.currentTime presentz-1.2.0.min.js:19
initPresentz 
(anonymous function) 
l jquery.min.js:2
c.fireWith jquery.min.js:2
v.extend.ready jquery.min.js:2
A

@player object is created only when I call changeVideo in https://github.com/ffissore/presentz.js/blob/master/src/Youtube.coffee#L29.

Then tried

var t = presentz.presentation.chapters[0].video._plugin;
t.changeVideo({url: presentz.presentation.chapters[0].video.url});
console.log(presentz.presentation.chapters[0].video._plugin.currentTime()); // or
console.log(t.presentation.chapters[0].video._plugin.currentTime());

Uncaught TypeError: Cannot read property 'getCurrentTime' of undefined

ffissore commented 11 years ago

I've just pushed 1.2.1 with a null check on @player. You should call that function once the player is set up: that depends on the player and its backend (youtube may sometimes be slow)

BTW: I sugget you to avoid using the minified version while developing, as it reports useless code lines

kracekumar commented 11 years ago
function youtube() {
            var t = presentz.presentation.chapters[0].video._plugin;
            t.changeVideo({url: presentz.presentation.chapters[0].video.url});
            /*for (var item in t){
              console.log(item);
            }*/
            console.log(t.player);
            console.log(t.currentTime());            
          }
presentz.presentation.chapters[0].video._plugin.ensureYoutubeIframeAPILoaded(youtube);

Error: Uncaught ReferenceError: YT is not defined presentz-1.2.1.js:326

ffissore commented 11 years ago

you are manually calling functions that presentz calls on its own, when it knows it can call them: you should know what you're doing

btw, I've just recall presentz emit a "timechange" event

presentz.on("timechange", function(currentTime) { ... });
kracekumar commented 11 years ago

Thanks, that makes clear.