Using YouTube API in AngularJS/Javascript - javascript

I'm just trying to do some simple calls on youtube videos such as using their seekTo() method and getTimeStamp() sort of thing. I'm struggling to follow the documentation and was wondering if anyone knew of any example code I could look at?
e.g. Working with embedded videos -
Currently using -
Is it as simple as adding enablejsapi=1 like so?
link = http://www.youtube.com/v/VIDEO_ID?version=3&enablejsapi=1
How exactly do you call methods such as seekTo() etc. then? Sorry if this is unclear.

As JCD indicated as well, the YouTube Player API is a great starting point for what you might need to do.
It goes into detail on where to start, how to load videos, JS functions used, etc.
seekTo(...) requires 2 parameters, seconds and allowSeekAhead. Its recommended to set allowSeekAhead to false when the user is dragging the progress bar and true when user releases it.

Related

options for implementing a PowerPoint viewer on HTML for a web app (other than embedding with provided i-frame tag)

Here's what I'm trying to accomplish: displaying a PowerPoint presentation on HTML. The user should be able to start and execute the presentation exactly like when you press the "Start Presentation" button in Microsoft PowerPoint: it goes fullscreen, transitions and animations are played, it goes to the next slide if a duration for the slide is set, on click it goes to the next slide, arrow keys are used for navigating slides and so on. Only need to run the presentation, NOT editing.
I've been looking around and came up with these three approaches:
Creating the viewer from scratch and processing/reading the .pptx file using HTML, CSS and JS, btw is this is feasible?
I know it won't be easy, but it seems it would take a lot of time to develop (I'm just one person working in the project).
Also free or paid approaches both are fine, the more options I get to know the better.
WOPI host, the problem with this is I need a paid Office365 membership.
Embedding using a third party such as Office Online, Google Docs, slides.com, the problem I noticed is that the i-frame they provide lacks from functionality and customization.
So my question is, are there other approaches for this? or is this all there is?
Final Edit: I decided to go with iSpring Converter Pro. Seems like the best option overall
Insane amount of work -> not worth it. But you could use a paid library such as Aspose.Slides
MS WOPI is, indeed, a way to do that. WOPI clients such as Office Online and Office Online Server offer an action called present. That's what you're looking for.
What about SlideShare's API and oEmbed?
Another approach:
Convert the PPTX to ODF and use https://viewerjs.org/

How do I delay a SurveyMonkey pop-up?

We're hoping to get feedback on a new site launch (beta; site will fully launch March 28). To give end users the chance to explore the site, we'd like the pop-up to appear after 10 seconds. I'm extremely new to coding JavaScript on my own, so any help is greatly appreciated.
I found an answer to a very similar question (and indeed, some answers seemed more specific to my situation): delayed pop-up code; however, I can't get the code to work on my site.
The pop-up is embedded using this JavaScript, supplied by SurveyMonkey. There's no associated HTML or CSS.
(function(t,e,s,o){var n,c,l;t.SMCX=t.SMCX||[],e.getElementById(o)||(n=e.getElementsByTagName(s),c=n[n.length-1],l=e.createElement(s),l.type="text/javascript",l.async=!0,l.id=o,l.src=["https:"===location.protocol?"https://":"http://","widget.surveymonkey.com/collect/website/js/tRaiETqnLgj758hTBazgd8fe_2Bhm5gFnGqBOI61Z1zZLxwDFd6OcUAaoSp03T3t6v.js"].join(""),c.parentNode.insertBefore(l,c))})(window,document,"script","smcx-sdk");
And this is the code I currently have, modified from one of the answers in the previous post.
function OpenSurvey(t,e,s,o){};
window.setTimeout(function(){ OpenSurvey(window,document,"script","smcx-sdk"); }, 10000);
I was running into the same issue today and I managed to get it working with this code. I hope this helps:
setTimeout(function(){ OpenSurvey(window,document,"script","smcx-sdk"); }, 60000);
function OpenSurvey(t,e,s,o){var n,a,c;t.SMCX=t.SMCX||[],e.getElementById(o)||(n=e.getElementsByTagName(s),a=n[n.length-1],c=e.createElement(s),c.type="text/javascript",c.async=!0,c.id=o,c.src=["https:"===location.protocol?"https://":"http://","widget.surveymonkey.com/collect/website/js/xxxxxxx.js"].join(""),a.parentNode.insertBefore(c,a))}
I had this exact same issue and was beating my head into my desk trying to make this work by editing the code snippet from SurveyMonkey. I called SurveyMonkey and the most they could do was to send me an additional snippet with some new handlers - didn't work. Finally, I was about to call WIX and while making my way down the tree to find the best phone option for me, the site suggested I try reading the tutorial on embedding 3rd party code. BINGO!
Long story short, click this link and follow the instructions - ridiculously easy to implement and you don't have to paste the snippet into the page code - there is a specific section in the Advanced Setting of your site Dashboard (not the WIX account dashboard or the editor, if you ARE on the WIX dashboard click on your sites thumbnail and look for Settings in the dark blue right rail, then click Advanced Settings in the body of the page). Link to WIX instructions for 3rd party code below:
https://support.wix.com/en/article/embedding-custom-code-to-your-site#working-with-third-party-code
Good luck with your endeavores and I really hope this helps! The most challenging part of this was honestly getting the dashboards confused until I realized they meant to go to that particular site's settings.
BrZrKr

Alexa skill to control logitech squeezebox - request to modify code

I've been trying to set up an alexa application called muzak - https://github.com/lordpengwin/muzak - which allows control of logitech squeezeboxes using Echo.
The code works fine, but the play function is set to select random tracks which is not that helpful.
I'd like to be able to use the play function to simply play (or toggle/pause) whatever is on the current playlist.
It can't be that much of a change required to the code to allow this, presumably changing the randomPlay piece in line 254 of the muzak.js https://github.com/lordpengwin/muzak/blob/master/muzak.js file. I've tried changing this to play, pause, toggle etc. but none of those seem to work.
Grateful for any suggestions on how the code could be updated to allow current playlist to be played.
Thanks.
Haven't had a chance to test this out yet, but...
It's probably play(callback) and pause(callback) you want to use. Should be pretty simple - remember to remove that first parameter though, as it's not needed for these functions.
See the example of play(callback).

Greasemonkey with Youtube

So, I decided that starting small with learning either Javascript or Greasemonkey one at a time was just not ambitious or efficient enough. So I decided to make a Greasemonkey script that alters the way Youtube works.
I'll start with problems I am pretty sure it isn't, I do have the HTML5 player enabled, and I double checked the names of the functions I am calling in the Youtube API. I am also pretty sure that I installed Greasemonkey correctly and that the script is loading correctly, based on the fact that when a Youtube page is open, the "YoutubeSpeed.user.js" file is in the Greasemonkey context menu with a check mark next to it, and that I tried installing a much simpler Greasemonkey script (http://www.wired.com/wired/archive/webmonkey/greasemonkey/helloworld.user.js) and it worked just fine. In case it isn't obvious, I am basically trying to have Youtube do a bunch of stuff as soon as a video is opened. (specifically, have it pause, set the speed to 2x, set the quality to 720p, and make sure the volume is at 100.
I think the problem is either with my use of the Youtube API, or my use of Javascipt syntax, or my use of Greasemonkey syntax. I really think these could all be useful tools going forward, so a little help learning them would be much appreciated. Also, any other ideas for improving the general Youtube experience to add to this script would be appreciated as well.
EDIT: Ah, it seems there was a mistype. I absolutely meant to include my script, and since it's pretty short, I hope you guys will be able to help me. Here it is in all it's glory.
// ==UserScript==
// #name YoutubeSpeed
// #namespace matt47721#yahoo.com
// #description Double The Speed Of Youtube Videos By Default
// #include https://www.youtube.com/*
function onPlayerReady() {
target.player.pauseVideo();
target.player.setPlaybackRate(2);
target.player.setPlaybackQuality(hd720);
target.player.unMute();
target.player.setVolume(volume:100);
};
// #grant none
// ==/UserScript==
As to an MCVE, for M, I have been unable to make any Greasemonkey script involving Youtube videos work. As for the C, the entirety of my script is there. And as for the V, I guess I could have described that a little better, my apologies. When I open a Youtube video, it does none of the things I am trying to accomplish with this script, it just plays normally. And since the question is about how to make my Greasemonkey script work with Youtube, and the only code I put in is the Greasemonkey script that is supposed to affect Youtube I would say I've eliminated things not relevant to the problem.
I hope this is satisfactory, I apologize for doing so poorly before, this is my first time using StackOverflow.
Cheers,
Eridine
Your script references a variable "target.player" but you haven't linked that variable to the player on the youtube page. You need to first find the player using something like:
var videoElement = document.getElementsByTagName("video")[0];
which gives you a handle to the video player, only then can you manipulate the player using the API. A complete, working, script can be found here:
https://github.com/mirnhoj/video-element-playbackrate-setter/

Soundcloud windget setVolume not working at all

Soundcloud widget is a great thing but volume control is completely broken. JS api calls to setVolume just ignored by player, tested in latest Chrome and Firefox.
Broken volume control can be easily seen at official playground page - https://w.soundcloud.com/player/api_playground.html
Some time ago there was workaround - SoundCloud Widget API setVolume Method broken? - but now even this hack does not work. Please fix widget API. without volume control it is almost unusable ( Btw, workaround is not ok anyway, since first second of loaded sound still playing at full volume, hiting site visitor with "overloaded" sound
UPDATE: Just found the reason.
Seems like setVolume/getVolume range is now 0..1, not 0..100 as it was earlier
Documentation and playground just didn`t updated yet

Categories

Resources