Is it possible via the SoundCloud API to get the current playing trackname ? Via the widget it's ok but it will be better (UX point of view) if I could without.
I found nobody mention it, if you have an idea, you're welcome !
Thx
I'm currently looking to do the same thing. Seems that the only way to do it via the API is to use what they call "activities" : https://developers.soundcloud.com/docs/api/reference#activities
So you can have a list of all activities made by a user, which includes the listening of a track. But I assume the activity will appear in the list only once the music has been played, not while the music plays.
Has anyone already used that functionnality ?
Regards,
Seb
I coded this litlle script that bind DOM's updates but it's very tricky.
// Bind new song on the soundcloud player
$('.playbackSoundBadge').bind('DOMSubtreeModified', function(e){
track_info = e.target;
if(track_info.className.indexOf('sc-media-image') > -1){
thumb = track_info.querySelector('span');
if(thumb != null){
splitted_url = track_info.href.split(/\//);
playing.artist = splitted_url[3];
playing.trackname = splitted_url[4];
thumb = track_info.querySelector('span');
playing.thumbnail = standardizeThumb(thumb.style.backgroundImage);
toaster(playing);
}
}
});
// Toast factory
function toaster(playing){
// Is there already a toast ?
toast = document.getElementById('sc-toast');
if(toast == null){
toast = document.createElement('div');
toast.id = 'sc-toast';
document.body.appendChild(toast);
}else{
toast.innerHTML = '';
}
// Build our toast
thumb = document.createElement('img');
thumb.src = playing.thumbnail;
toast.appendChild(thumb);
wrapper = document.createElement('div');
wrapper.className = 'wrapper-text';
playing.artist = standardizeString(playing.artist);
playing.trackname = standardizeString(playing.trackname);
artist = document.createElement('h1');
artist.innerHTML = playing.artist;
trackname = document.createElement('h2');
trackname.innerHTML = playing.trackname;
wrapper.appendChild(artist);
wrapper.appendChild(trackname);
toast.appendChild(wrapper);
}
Related
I have below structure, I need to parse every ID on button click, Insort I need ID to another screen. Anyone please help me to do this.
SCREEN 1 :
expected SCREEN 2 :
Welcome to ID : [DYNAMIC ID from Last PLAY btn click]
Software/platform I am working on
Unity 2D Version 2019.3.7f*, Data come from MongoDB Json
foreach (var document in playercollection.Find(where14))
{
var dotNetObj = BsonTypeMapper.MapToDotNetValue(document);
var jsonstring = JsonConvert.SerializeObject(dotNetObj);
TableClass myObject = JsonUtility.FromJson<TableClass>(jsonstring);
table_data.text = myObject.table_name;
table_boot.text = myObject.boot;
table_pot.text = myObject.pot_limit;
GameObject newitems = Instantiate<GameObject> (itemPrefab, transform);
}
You can add onclick listener dynamically and pass the id. Assuming you are adding this UI rows dynamically if yes then you can do the following:
button.onClick.AddListener(() => ButtonClicked("my_id"));//write this in the loop or where you are generating UI rows.
void ButtonClicked(string id)
{
Debug.Log("Button clicked = " + id);
}
Based on your edited question and assumption itemPrefab has a Button component attached following should work.
foreach (var document in playercollection.Find(where14))
{
var dotNetObj = BsonTypeMapper.MapToDotNetValue(document);
var jsonstring = JsonConvert.SerializeObject(dotNetObj);
TableClass myObject = JsonUtility.FromJson<TableClass>(jsonstring);
table_data.text = myObject.table_name;
table_boot.text = myObject.boot;
table_pot.text = myObject.pot_limit;
GameObject newitems = Instantiate<GameObject> (itemPrefab, transform);
newItems.GetComponent<Button>().AddListener(() => ButtonClicked("my_id"));//use id from the document
}
I'm using this piece for hide/show selected layer:
app.activeDocument.activeLayer.visible = !app.activeDocument.activeLayer.visible;
I wonder if there exist a way of toggling a non selected layer by it's name.
Many thanks
Update:
I got it working with this thing (I know, it must be cleaned):
function toggleLayer() {
for( var i = 0; i < app.activeDocument.artLayers.length; i++) {
if (app.activeDocument.artLayers[i].name == "theLayer"){
app.activeDocument.artLayers[i].allLocked = false;
app.activeDocument.artLayers[i].visible = !app.activeDocument.artLayers[i].visible;
}
}
}
I'd like to know if we can do the same without the loop.
Thanks
Here is the solution I did write. Unexpectedly it worked :P
function toggleLayer() {
var tl = app.activeDocument.layers["theLayer"];
tl.visible = !tl.visible;
}
toggleLayer();
Now, I have another doubt: Whats the difference between "layers" and "artLayers"?
Cheers
I am trying to update some popups in my map but I am not able to do that.
Firstly I create some markers, and with the next code, I create a popup associated to them. One popup for each marker:
popFeature = new OpenLayers.Feature(markers, location);
popFeature.closeBox = true;
popFeature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {
'autoSize': true
});
popFeature.data.popupContentHTML = "hello";
popFeature.data.overflow = (false) ? "auto" : "hidden";
var markerClick = function (evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
this.popup.toggle();
}
currentPopup = this.popup;
OpenLayers.Event.stop(evt);
};
mark.events.register("mousedown", popFeature, markerClick);
After that, I add the new marker to my marker layer.
Everything is fine until here, but, I want to update the popupcontentHTML some time later and I don't know how I can access to that value.
I read OL API but I don't understand how to get it. I am lost about features, events, extensions...
I want to know if I can access to that property and write other word.
I answer myself, maybe it helps other people in future:
for(i = 0; i < map.popups.length; i++){
if(map.popups[i].lonlat.lon == marker.lonlat.lon){
map.popups[i].setContentHTML("new content");
}
}
Content will be refreshed at the moment.
system.logElementTree();
var target = UIATarget.localTarget();
target.onAlert = function onAlert(alert) {
UIALogger.logDebug("There was an alert!");
target.onAlert.buttons()["No"].tap({x:164,y:278});
return false;
even though no option is clicked systen not performing any action
Can anyone please help me ...
Instead of BamboOS suggestion which loops through various positions, you can try this inside your onAlert function:
alert.tapWithOptions({tapOffset:{x:0.5, y:0.6}});
This tap targets the middle of the UIAAlert (x:0.5) and 60% from top to bottom (y:0.6). This works when there is only one button. You have multiple buttons, then you have to changed the value of x. This works for me.
I just published a blog post regarding UI Automation and dealing with alerts:
http://www.conduce.net/Blog.aspx?f=Automated-Test-of-iPad-Apps
Basically following alert handler worked for me:
UIATarget.onAlert = function onAlert(alert){
var name = alert.name();
UIALogger.logMessage("alert "+name+" encountered");
if(name == "errorAlert"){
var positionX = 500;
for(var positionY=300; positionY<600;positionY+=10){
target.tap({x:positionX,y:positionY});
}
return true;
}
return false;
}
I would either use the "cancelButton" or "defaultButton" methods when handling alerts.
I was hunting for an implementations of YUI AutoComplete and I came across this script from the site asklaila.com -
<script type="text/JavaScript">
YAHOO.example.ACJson = new function() {
this.oACDS = new YAHOO.widget.DS_XHR("/AutoComplete.do",
["Suggestions[0].Results","Name"]);
this.oACDS.queryMatchContains = true;
this.oACDS.scriptQueryAppend = "city=Mysore"; // Needed for YWS
function fnCallback(e, args) {
document.searchForm.where.focus();
acSelected = true;
return false;
}
this.oAutoComp = new YAHOO.widget.AutoComplete('what','whatContainer', this.oACDS);
this.oAutoComp.itemSelectEvent.subscribe(fnCallback);
this.oAutoComp.formatResult = function (oResultItem,sQuery) {
return oResultItem[0];
}
this.oAutoComp.queryDelay = 0;
this.oAutoComp.useIFrame = true;
this.oAutoComp.prehighlightClassName = "yui-ac-prehighlight";
this.oAutoComp.minQueryLength = 2;
this.oAutoComp.autoHighlight = false;
this.oAutoComp.textboxFocusEvent.subscribe(function() {
this.oAutoComp.sendQuery("");
});
this.oAutoComp.doBeforeExpandContainer = function(oTextbox, oContainer, sQuery, aResults) {
var pos = YAHOO.util.Dom.getXY(oTextbox);
pos[1] += YAHOO.util.Dom.get(oTextbox).offsetHeight + 2;
YAHOO.util.Dom.setXY(oContainer,pos);
return true;
};
}
</script>
It is implenting the YUI AutoComplete Dropdown. What I want to understand is what this
this.oACDS = new YAHOO.widget.DS_XHR("/AutoComplete.do", ["Suggestions[0].Results","Name"]);
does and its effects on code.
That's using an older version of YUI, but it is setting up a DataSource for the autocomplete to read from. This particular DataSource uses XHR to request information from the server to populate the autocomplete field.
"Autocomplete.do"
Is a relative URL that is being queried by the DataSource every time the autocomplete fires while the user is typing.
["Suggestions[0].Results","Name"]
Is the responseSchema that tells the DataSource how to parse the results from the request to the URL. It needs to know how to parse the data so that it can show the proper results.
this.oACDS = new YAHOO.widget.DS_XHR("/AutoComplete.do", ["Suggestions[0].Results","Name"]);
On every key press, it fetches a json response from the server, and uses it to populate the autocomplete dropdown. The json contains names to display only at this node, "Suggestions[0].Results" in the "name" field.
If you have any trouble, ask ahead. I wrote that piece of code for asklaila.com
I was hunting for implementations of
YUI Autocomplete and I came across
this script...
Why not take a look at YUI AutoComplete page for in-depth examples.
Yahoo! UI Library: AutoComplete