innerHTML call to receive a url - function

I am trying to make a call so that when a title of a video is clicked on in my playlist, it will call back a particular videos url to be shown in the metadata field box that I have created.
So far I am getting results but the function below that I am using is giving me rmtp url's like this:
(rtmp://brightcove.fcod.llnwd.net/a500/d16/&mp4:media/1978114949001/1978114949001_2073371902001_How-to-Fish-the-Ice-Worm.mp4&1358870400000&7b1c5b2e65a7c051419c7f50bd712b1b
)
Brightcove has said to use (FLVURL&media_delivery=http).
I have tried every way I know of to put a media delivery in my function but always come up with nothing but the rmtp or a blank.
Can you please help with the small amount of code I have shown. If I need to show more that is not a problem. Thanks
function showMetaData(idx) {
$("tr.select").removeClass("select");
$("#tbData>tr:eq("+idx+")").addClass("select");
var v = oCurrentVideoList[idx];
//URL Metadata
document.getElementById('divMeta.FLVURL').innerHTML = v.FLVURL;
Here is my Population call for my list.
//For PlayList by ID
function buildMAinVideoList() {
//Wipe out the old results
$("#tbData").empty();
console.log(oCurrentMainVideoList);
oCurrentVideoList = oCurrentMainVideoList;
// Display video count
document.getElementById('divVideoCount').innerHTML = oCurrentMainVideoList.length + " videos";
document.getElementById('nameCol').innerHTML = "Video Name";
//document.getElementById('headTitle').innerHTML = title;
document.getElementById('search').value = "Search Videos";
document.getElementById('tdMeta').style.display = "block";
document.getElementById('searchDiv').style.display = "inline";
document.getElementById('checkToggle').style.display = "inline";
$("span[name=buttonRow]").show();
$(":button[name=delFromPlstButton]").hide();
//For each retrieved video, add a row to the table
var modDate = new Date();
$.each(oCurrentMainVideoList, function(i,n){
modDate.setTime(n.lastModifiedDate);
$("#tbData").append(
"<tr style=\"cursor:pointer;\" id=\""+(i)+"\"> \
<td>\
<input type=\"checkbox\" value=\""+(i)+"\" id=\""+(i)+"\" onclick=\"checkCheck()\">\
</td><td>"
+n.name +
"</td><td>"
+(modDate.getMonth()+1)+"/"+modDate.getDate()+"/"+modDate.getFullYear()+"\
</td><td>"
+n.id+
"</td><td>"
+((n.referenceId)?n.referenceId:'')+
"</td></tr>"
).children("tr").bind('click', function(){
showMetaData(this.id);
})
});
//Zebra stripe the table
$("#tbData>tr:even").addClass("oddLine");
//And add a hover effect
$("#tbData>tr").hover(function(){
$(this).addClass("hover");
}, function(){
$(this).removeClass("hover");
});
//if there are videos, show the metadata window, else hide it
if(oCurrentMainVideoList.length > 1){showMetaData(0);}
else{closeBox("tdMeta");}
}

If looking for HTTP paths, when the API call to Brightcove is correct you won't see the rtmp:// urls.
Since you're getting the rtmp URLs, this verifies you're using an API token with URL access, which is good. A request like this should return the playlist and the http URLs (insert your token and playlist ID).
http://api.brightcove.com/services/library?command=find_playlist_by_id&token={yourToken}&playlist_id={yourPlaylist}&video_fields=FLVURL&media_delivery=http
This API test tool can help build the queries for you, and show the expected results:
http://opensource.brightcove.com/tool/api-test-tool
I'm not seeing what would be wrong in your code, but in case you haven't tried this already, debugging in the browser can help you confirm the API results being returned, without having to access it via code. This help you root out any issues with the code you're using to access the values, vs problems with the values themselves. This is an overview on step-debugging in Chrome if you haven't used this before:
https://developers.google.com/chrome-developer-tools/docs/scripts-breakpoints

Related

Scraping using Html Agility Package

I am trying to scrape data from a news article using HtmlAgilityPackage the link is as follows http://www.ndtv.com/india-news/vyapam-scam-documents-show-chief-minister-shivraj-chouhan-delayed-probe-780528
I have written the following code below to extract all the comments in this articles but for some reason my variable aTags is returning null value
Code:
var getHtmlWeb = new HtmlWeb();
var document = getHtmlWeb.Load(txtinputurl.Text);
var aTags = document.DocumentNode.SelectNodes("//div[#class='com_user_text']");
int counter = 1;
if (aTags != null)
{
foreach (var aTag in aTags)
{
lbloutput.Text += lbloutput.Text + ". " + aTag.InnerHtml + "\t" + "<br />";
counter++;
}
}
I have also used this XPath but still the same result //div[#class='newcomment_list']/ul/li/div[#class='headerwrap']/div[#class='com_user_text']
Please help me with the correct Xpath to Extract all the comments
Searched all over the net but no solution.
Do a 'View Source' on the page and search for com_user_text. The user comments don't appear at all. They are loaded via javascript after the page is loaded. So when you load the page content via getHtmlWeb.Load(), you don't get user comments.
As this answer says, HTML Agility is not a tool capable of emulating a browser and running javascript. Instead, you need something like WatiN that "allows programmatic access to web pages through a given browser engine and will load the full document."

Phonegap GetJson Strange Output - REST

I am having this situation: ( public api a test website of mine )
$.getJSON("http://ee-tutz.com/entry_api/rest/read_entry/json?auth[username]=test&auth[password]=guest&data[entry_id]=80",function(data){
alert(data); // here i get [obj Obj]
var tweetlistHTML = "";
for(var i = 0; i< data.results.length;i++){
tweetlistHTML +='<li>'+data.results[i].title+ '</li>'
}
var tweetList = $("#tweetlist");
tweetList.html(tweetlistHTML);
});
Is anything worng with the code ?
I want to output some data of out the resulting from the URL ( for example Title )
But it Doesen't Output the titles
Can you try to output the object details using JSON.stringify() method.
This will let you know the returned object properties and values.
e.g: alert the first object details.
alert(JSON.stringify(data.results[0]));
OR the entire objects in the array.
alert(JSON.stringify(data.results));
Also did you try to check the results form the desktop browser whether the URL is returning JSON response.
EDIT1:
I just checked the response of the URL
You need to change the data variable syntax.
data.data[i].title
instead of
data.results[i].title
EDIT2:
Oops. I forgot to change my alert code.
The alert should be.
alert(JSON.stringify(data.data[0]));
or you could alert the whole data.
alert(JSON.stringify(data));
EDIT3:
Your JSON data returned by the URL
http://ee-tutz.com/entry_api/rest/read_entry/json?auth[username]=test&auth[password]=guest&data[entry_id]=80
JSON data:
{"message":"Successfully readed","code":200,"code_http":200,"data":[{"entry_id":"80","site_id":"1","channel_id":"1","author_id":"1","forum_topic_id":null,"ip_address":"86.120.164.135","title":"POP ON OP: an Interactive Real-Time Animation Object-Book","url_title":"pop-on-op-an-interactive-real-time-animation-object-book","status":"open","versioning_enabled":"y","view_count_one":"0","view_count_two":"0","view_count_three":"0","view_count_four":"0","allow_comments":"y","sticky":"n","entry_date":"1405812194","year":"2014","month":"07","day":"20","expiration_date":"0","comment_expiration_date":"0","edit_date":"20140719233024","recent_comment_date":"0","comment_total":"0","main_content":"POP ON OP is an interactive real-time animation object-book in which you can experience movement directly on paper with a special film.","propietati":"74%$23,959 Funded ","testfisier":false,"poza":"<img alt=\"Photo little\" class=\"fit\" height=\"150\" src=\"https:\/\/s3.amazonaws.com\/ksr\/projects\/1055334\/photo-little.jpg?1404412397\" width=\"200\" \/>","descriere":" POP ON OP is an interactive real-time animation object-book in which you can experience movement directly on paper with a special film. ","autor":" by PARRATORO ","categories":[]}],"id":"80"}

Soundcloud HTML5 Player: Events.FINISH only fired once

I'm using the SC HTML5 player, when one sound finishes, I load in another source, however the FINISH event only seems to fire for the first song, my code is as follows
//Set the source
document.getElementById("sc-widget").src = scPath;
//get the widget reference
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
//set the finish event
widget.bind(SC.Widget.Events.FINISH, endSC);
function endSC() {
var scPath = "http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F1848538&show_artwork=true&auto_play=true";
document.getElementById("sc-widget").src = scPath;
var widgetIframe = document.getElementById('sc-widget'),
widget = SC.Widget(widgetIframe);
widget.bind(SC.Widget.Events.FINISH, endSC);
}
I've tried setting the endSC target to another function but that doesn't work, what am I missing? Thanks!
I had the same problem. SC.Widget method is working fine when I call it for the first time, but if I try to call it for the second time the console will fire "Uncaught TypeError: Cannot read property 'parentWindow' of null" error in http://w.soundcloud.com/player/api.js script. And that is where api.js script stops with actions (.Widget, .bind, etc.)
I found the solution. It's very weird, but it is a solution.
SoundCloud remote script is minified. Load it in your browser, C/P it in some online js beautifier and save it locally. Edit line 103 as follows:
return a.contentWindow;// || a.contentDocument.parentWindow
So I removed that .parentWindow call.
Save the file and call it in your page's head section. And that's it! Now FINISH event fires on every loaded widget.
I hope this will help.
Looks like this question is over 10 years old, but it just came up for me now.
I recreated the iframe div from scratch. Otherwise, the SC.Widget.Events.FINISH will only fire when the original embed player finishes.
You must reset the DOM element events by completely recreating the iframe element, like so:
//EXAMPLE SC SONG IDs
let songIds = [216109050, 779324239, 130928732]
let incrementingIndex = 0
function playSongsInIframe() {
let iframeParent = document.querySelector('#sound-player')
let iframeElement = document.querySelector('#sound-player iframe')
iframeElement.remove()
//CODE TO ADD NEW SOUND IDs
//yourSoundId = songIds[incrementingIndex]
let newIframe = document.createElement('iframe')
newIframe.id = "sound-" + yourSoundId
newIframe.width = "100%"
newIframe.height = "166"
newIframe.scrolling="no"
newIframe.frameborder="no"
newIframe.allow = "autoplay"
newIframe.src = "https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/" + yourSoundId + "&auto_play=true"
iframeParent.appendChild(newIframe)
let widget = SC.Widget("sound-" + yourSoundId);
widget.bind(SC.Widget.Events.READY, () => {
console.log('Ready...');
widget.play()
});
widget.bind(SC.Widget.Events.FINISH, () => {
console.log('Song ended...');
incrementingIndex++
playSongsInIframe()
});
}
One last consideration - this process must be started from a user event, like a click. You can add this function to the onclick attribute of an HTML button element:
<button onclick="playSongsInIframe()">Start Radio</button>

Spotify List objects created from localStorage data come up blank

I'm working on a Spotify app and trying to create a views.List object from some stored information in our database. On initial load, a POST is made to get the necessary info. I store this in localstorage so each subsequent request can avoid hitting the database and retrieve the object locally. What's happening though is the List objects I create from localstorage data come up blank, while the POST requests work just fine.
Here is the snippet I'm using to create the list:
var temp_playlist = models.Playlist.fromURI(playlist.uri);
var tempList = new views.List(temp_playlist, function (track) {
return new views.Track(track, views.Track.FIELD.STAR |
views.Track.FIELD.NAME |
views.Track.FIELD.ARTIST |
views.Track.FIELD.DURATION);
});
document.getElementById("tracklist").appendChild(tempList.node);
playlist.uri in the first line is what I'm retrieving either from a POST or from localstorage. The resulting views.List object (tempList) looks identical in both cases except for tempList.node. The one retrieved from localstorage shows these values for innerHTML, innerText, outerHTML, and outerText in console.log:
innerHTML: "<div style="height: 400px; "></div>"
innerText: ""
outerHTML: "<div style="height: 400px; "></div>"
outerText: ""
Whereas the one retrieved via POST has the full data:
innerHTML: "<div style="height: 400px; "><a href="spotify:track:07CnMloaACYeFpwgZ9ihfg" class="sp-item sp-track sp-track-availability-0" title="Boss On The Boat by Tosca" data-itemindex="0" data-viewindex="0" style="-webkit-transform: translateY(0px); ">....
innerText: "3Boss On The BoatTosca6:082....
and so forth..
Any help would be greatly appreciated
Solved this.
I am using hide() and show() to render the tabs in my app. I was constructing the tracklist and then show()ing the div which led to a blank tracklist. If I simply show() the div and then construct the tracklist it works fine.
The reason (I think) it was working for POSTs is because the tracklist was retrieved from the database and the slightly longer loading time probably meant the tracklist was constructed after the div's show() executed. With localStorage I guess the tracklist was constructed before the div was even shown, leading to the error.
Using, the local storage, I did it this way :
sp = getSpotifyApi(1);
var m = sp.require("sp://import/scripts/api/models");
var v = sp.require("sp://import/scripts/api/views");
var pl;
pl = m.Playlist.fromURI(uri);
var player = new v.Player();
player.track = pl.get(0);
player.context = pl;
var list = new v.List(pl);
XXXXX.append($(list.node));
Hope, it will help, as it's working for me
I think I've actually managed to solve this and I think it's bulletproof.
Basically I was trying to solve this by trying to convince the API that it needed to redraw the playlist by hiding things/scrolling things/moving things which worked occasionally but never consistently. It never occurred to me to change the playlist itself. Or at least make the API think the playlist has changed.
You can do so by firing an event on the Playlist object.
var models = sp.require('$api/models');
...
// playlist is your Playlist object. Usually retrieved from models.Playlist.fromURI
playlist.notify(models.EVENT.CHANGE, playlist);
These are just standard Spotify functions and the list updates because it thinks something has changed in the playlist. Hope this helps someone!

How to send dynamically generated variables via ajax, using post method

I've an html page wich contains a table, some rows and inside any row i checkbox.
When i select a checkbox i will to delete the message BUT only when i click a red-button-of-death.
Example
table
tr(unique_id)
td [checkbox]
td Content
td Other content
[... and so on]
/table
[red-button-of-death]
Now, the delete of multi rows must be without the reload of the page so i set up an ajax function that work like this:
setup ajax object.
set the open method (post/get, url, true)...
wait for the response of the "url" page.... take a coffe, have a break.
got response, using jquery delete the row using the unique id of the rows.
jquery: popup a feedback for the action just done
jquery: update some counter around the page
So, i begin tryin to delete a single record and everything go fine, i has created a link on every rows that call the function to delete "single record" passing the id of the item.
But now i've to develop the multi-delete-of-doom.
the first thing that i've think was "i can envelop the table in a 'form' and send everything with the 'post' method".
That seems to be brilliant and easy....
but doesn't work :-|
Googling around i've found some example that seems to suggest to set a variable that contains the item to send... so, trying to follow this way i need a method to get the name/id/value (it's not important, i can populate an attribute with the correct id) of the selected checkbox.
Here the function that make the ajax call and all the rest
function deleteSelected() {
var params = null;
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("post", "./cv_delete_pm.php?mode=multi", true); //cancella i messaggi e ritorna l'id delle righe da cancellare
//Send the proper header information along with the request
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
http.setRequestHeader("Content-length", params.length);
http.setRequestHeader("Connection", "close");
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status != 404) {
var local = eval( "(" + xmlhttp.responseText + ")" );
/*
//cancella gli elementi specificati dalla response
var Node = document.getElementById(local.id);
Node.parentNode.removeChild(Node);
loadMessagesCount('{CUR_FOLDER_NAME}'); //aggiorna sidebar e totale messaggi nel body
initTabelleTestate(); //ricrea lo sfondo delle righe
$("#msgsDeleted").attr("style", "left: 600px; top: 425px; display: block;");
$("#msgsDeleted").fadeIn(500);
$("#msgsDeleted").fadeOut(2000);
$("#msgsDeleted").hide(0);
*/
}
}
};
xmlhttp.send(params);
}
Actually the variable 'param' is set to null just because i'm doing some experimentation.
So, the questions
are:
- Is it possible to make an ajax request sending the content of the form? How?
- Is it possible to get the name/value/id (one of these) of all the selected checkbox of an html page? How?
Answer to one of these two question with the solution is enough to win my personal worship :)
Edit: I think you are using JQuery so look here: http://api.jquery.com/category/ajax/
You should be using a javascript frame work such as dojo or jquery to handle Ajax. Writing you own ajax functions from scratch is not recommended.
Some frameworks:
http://www.dojotoolkit.org/
http://www.jquery.com/ (http://api.jquery.com/category/ajax/)
http://mootools.net/
A jquery example (are you already using this framework?):
$.post("test.php", $("#testform").serialize());
A Dojo Example:
Submitting a form using POST and Ajax:
function postForm() {
var kw = {
url: 'mypage.php',
load: function(type, data, evt) {
dojo.byId("someElement").innerHTML=data;
},
formNode: dojo.byId("myForm"),
method: "POST",
error: function(type, data, evt){
//handle error
},
mimetype: "text/html"
};
dojo.io.bind(kw);
}
Update. Solved.
I've used the builtin function of jquery to manage the form sumbit using the $jQuery.post() function and the $(#idform).serialize() function. It's really late now but tomorrow i'll try to remember to paste here the correct code :)
Thanks for the answer anyway :)
Update (code below):
//Send by Post
function deleteSelected() {
$.post("./delete.php?mode=multi",
$("#pmfolder_form").serialize(),
function(data){
var local = eval( "(" + data + ")" );
//this delete the html via dom to update the visual information
for (var i = 0; i < local.length-1; ++i) {
var Node = document.getElementById(local[i]);
Node.parentNode.removeChild(Node);
}
});
}
The structure of the selectbox was something like:
<input type="checkbox" name="check_<? print $progressive_id; ?>" value="<? print $real_id; ?>"/>
That's all. :)