Dynamically adding song tag in yahoo web player in not working - yahoo

I am using Yahoo web player and certain steps in order to add song to yahoo web player playlist.
I am displaying list of songs.
On click on a song creating a dynamic song url using jquery and appending in the div tag.
Link Like: Song
I want add this link to yahoo web player playlist.
Code:
fileUrl = "<a href='http://www.example.com/data?v=yaariyaan'> Song </a>";
YAHOO.MediaPlayer.addTracks(fileUrl, 0, true);
YAHOO.MediaPlayer.play();
addTracks is not adding the link to the playlist.
I am also getting the error:
Error : "Uncaught TypeError: Cannot call method 'fadeIn' of undefined ";
How to fix it?

I had the same problem and the only way I could resolve it is to make the autoplay set to true, like this:
<script type="text/javascript">
var YMPParams =
{
autoplay:true
}
</script>
<script type="text/javascript" src="http://mediaplayer.yahoo.com/latest"></script>

Related

Yammer share button not firing with single click

I am trying to integrate Yammer share button https://developer.yammer.com/docs/share-button, I successfully implemented as instructed, but the only catch is first time it requires two click to fire up, later on single click seems to do the job. Here is the code below.
function clickSaveShare(){
var options = {
customButton : true, //false by default. Pass true if you are providing your own button to trigger the share popup
classSelector: 'homeBtn',//if customButton is true, you must pass the css class name of your button (so we can bind the click event for you)
defaultMessage: 'My custom Message', //optionally pass a message to prepopulate your post
pageUrl: 'www.microsoft.com' //current browser url is used by default. You can pass your own url if you want to generate the OG object from a different URL.
};
yam.platform.yammerShare(options);
}
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<span href="#" class="homeBtn" onclick="clickSaveShare(339,'Reverse KT')"> Click here to share</a>
<script>
</script>
<script type="text/javascript" src="https://s0.assets-yammer.com/assets/platform_social_buttons.min.js"></script>
<script type="text/javascript">yam.platform.yammerShare();</script>
</body>
</html>
Calling yam.platform.yammerShare() doesn't actually call the share to Yammer function despite its name. What it does is apply a click event to the specified DOM element so that when that element is clicked the Yammer popup will appear.
The reason you have to click the button twice is that the first time clickSaveShare is called, it calls yam.platform.yammerShare() which sets up a click event on the specified DOM element. The next time the button is clicked your click event has been replaced with the Yammer one so it works as expected.
One simple way to fix it given that you are including jQuery would be to use jQuery's document.ready event:
$(document).ready(function() {
var options = {
customButton : true,
classSelector: 'homeBtn',
defaultMessage: 'My custom Message',
pageUrl: 'www.microsoft.com'
};
yam.platform.yammerShare(options);
});
Here is a CodePen example of the above.

Get text of all div with a same class CasperJS

I am new in casperJS and, I will appreciate someone telling me how to scrape all information with the same css class of a website.
for example, there is a list of items and all items have the same css class, I want to retrieve all the list.
I would recommend using casper.getElementsInfo():
casper.start('https://www.example.com/', function () {
var example = this.getElementsInfo('.example');
this.echo(example[0].text);
});

How to use the YouTube iFrame API in Chrome and Firefox?

I have a YouTube video embedded on my site using an iFrame. I want to use the API to pause the video, but in Chrome I get an error:
Unsafe JavaScript attempt to access frame with URL http://subdomain.example.com/ from frame with URL http://www.youtube.com/embed/KmtzQCSh6xk?enablejsapi=1&origin=http://subdomain.example.com. Domains, protocols and ports must match.
In Firefox (3.6) I get this error:
Permission denied for <http://www.youtube.com> to call method Location.toString on <http://subdomain.example.com>.
I've tried putting the iFrame in myself or adding it with the API. Either way the player gets in, but I have no API control over it.
Here's the relevant part of my code:
<div id="player"></div>
<script type="text/javascript">
var tag = document.createElement('script');
tag.src = "http://www.youtube.com/player_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('player', {
height: '433',
width: '731',
videoId: 'KmtzQCSh6xk'
});
}
$("#pause_button").click(function(){
alert("Pausing " + player);//is undefined :(
player.pauseVideo();
});
</script>
How do I get browsers to allow the YouTube iFrame to access my page's main frame?
Thanks!
Ignore those warnings. The player should still work fine regardless.
Use the recently-introduced JavaScript Player API for iframe embeds.

HTML 5 audio tags not appearing in GreaseMonkey

I'm working on my first GM script, to replace the Flash previews on http://www.freesound.org with HTML 5 audio tags, and to add a download link to search results. I have the latter working fine, but I can't get the audio tag to display in Firefox 3.5.9. Here's my script:
// ==UserScript==
// #name FreeSound HTML 5 Preview
// #namespace http://thewordnerd.info
// #description Replace Flash-based sound previews on freesound.org with audio tags and add quick download links
// #include http://freesound.org/*
// #require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
// ==/UserScript==
$(document).ready(function() {
$("embed").remove();
$(".samplelist").each(function(index) {
sampleNo = $(this).find("a:first").attr("href").split("?")[1].split("=")[1];
userName = $(this).find("a:eq(1)").html();
title = $(this).find("a:first").html().replace(/ /g, "_");
url = "/download/"+sampleNo+"/"+sampleNo+"_"+userName+"_"+title;
$(this).find("script").replaceWith("<audio src='"+url+"' controls='controls' type='audio/wave'/>");
//$(this).find("audio").removeAttr("tabindex");
$(this).append("<a href='"+url+"'>Download</a>");
});
});
I can see the element in Firebug and it seems just fine.
Thoughts on what I might be doing wrong here? Since the download link does download the requested file, since it's a wave and since I think I've set the correct type, I'm at a loss as to why this isn't displaying.
It may not be your script so much as the freesound.org site/server.
When I run a modified version of your script, the audio controls all appear for a split second before reverting to the error display, like so:
Firefox reports MEDIA_ERR_SRC_NOT_SUPPORTED for the files I checked.
Save this code to your machine and then run it with Firefox:
<html>
<head>
<title>Audio File test</title>
</head>
<body>
<audio id="aud1" controls="true" type="audio/ogg"
src="http://www.freesound.org/download/7521/7521_abinadimeza_Rainfall.ogg">xxx</audio>
<audio id="aud2" controls="true" type="audio/ogg"
src="http://developer.mozilla.org/#api/deki/files/2926/=AudioTest_(1).ogg">xxx</audio>
</body>
<script type="text/javascript">
window.addEventListener ("load", ErrorReport, false);
function ErrorReport (evt)
{
console.log (document.getElementById ("aud1").error);
console.log (document.getElementById ("aud2").error);
}
</script>
</html>
.
You'll see that the known good file, from Mozilla, works correctly but the one from freesound.org does not. This may be a bug/limitation in Firefox -- both files play fine on my local player.
Here is a link to the Firefox bug system, to search for or report bugs.

Tracking a page in an Ajax Popover from Google Analytics

I am looking to track a Pop-Over page that appears when the forum is
submitted at:
http://www.xebra.com/salesAssistance.html
I tried adding the urchin/google analytics code to the page that is displayed in the pop-over window, but whenever I do so the status bar displays "Read http://www.google-analytics.com/" and the entire form page goes blank.
It is important to track the page in the popover because that page is the conversion goal (the page we are trying to direct people to).
How do I stop Google Analytics from destroying my window, while still tracking that a user has been there?
Thank you,
Andrew J. Leer
You could separate your google analytics code into two bits:
one that goes on top of the page:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("#########");
} catch(err) {}
</script>
and the other just before the "end body" tag
<script>
pageTracker._trackPageview();
</script>
And the call the pageTracker._trackPageview(); method in the ajaxComplete callback of the "pop-up" window.

Resources