last day (15 days later) » 

8:54 PM
1
A: jquery store urls into an array and open them using .click(); function with controls

Xotic750To show show you how simple it is to impliment RingArray for use with your code example. CSS body { color: #fff; } .link { width: 180px; height: 20px; padding: 10px; background-color: black; cursor: pointer; text-align: center; } HTML <div class="resources"> <...

 
when i used the console.log it logged the correct URL however, nothing else happens. I believe that it needs to be able to click the whole anchor element, because only then the song plays<a href="example.com class="player">song name</a> when I click this myself it only works then.
 
Sure, you have to add the .click() code to the code that I have demonstrated, I just logged the output for you to see that the RingArray works, you need to do something like $(linkRing.increment(1).currentElement()).click() or whatever you want to do with the information stored at the currentElement.
If you don't know how to dispatch a click event, then that's another question, and there are many examples here on SO. Here is an example using pure modern Javascript stackoverflow.com/questions/24711051/… But I'm sure you can also find examples using jQuery if that is what you want.
 
I do know, and I had it added. Just forgot to post it to this comment. I also added an alert function and the correct URL is clicked however, for some reason the song doesn't change. Check this fiddle I just made, that's what I am trying to do, but with controls 'next' 'prev' 'current' jsfiddle.net/zctgyf88
 
I don't see a link to your current fiddle, with the RingArray code that I posted in my answer?
 
jsfiddle.net/zctgyf88 this is the idea, and because when you click on a link it starts playing I thought that I could implement this URL changer and the controls would play the next song previous etc
 
8:54 PM
Yes, that is the link that I went to, but I don't see any Javascript other than libraries being loaded, on that fiddle.
 
updated fiddler again no4 jsfiddle.net/0g7os0fp
 
Well, to begin with you have changed the class in the HTML from resources to post but not changed the jQuery selector to reflect this HTML change.
 
i changed it in the latest fiddler
 
You are also inluding jquery.min.js v1.4.2 as an external library, aswell as jQuery v1.9.1 from the menu and from the console it shows Uncaught TypeError: undefined is not a function as 1.4.1 is being loaded after 1.9.1 and doesn't have a method on Or so it seems
 
the github example uses jquery 1.4 only, however, 1.9 files are available for download and I am using them on my own machine. just don't have a cdn to upload them to fiddler: check this they're here: github.com/soundcloud/soundcloud-custom-player i am using: sc-player-minimal
 
8:54 PM
I'm sorry but I don't have the time to look into the soundcloud API or files. What I can say is that the RingArray works as expected (demonstrated in my answer) and from that you can then dispatch an event on the currentElement. what I can say is that soundcloud is using the deprecated live method, so if you are going to use 1.4.1 then you will need to change on to click (or something like that) in your code. Something like jsfiddle.net/Xotic750/xx05mn6e/6
 
but if the tracks play from inside the .post class only, it should somehow be possible to control them, maybe have only one URL by default and others stored in an array and replace the value of href attribute with the controls. i.e. 'next' button puts next url from array
 
We are way off topic from your original problem now, which was how to implement a ring array in Javascript.
 
it's still on topic because we're talking about replacing URL's with URL's from an array. Which we are close to doing now. I believe that what I mentioned in prior reply would work 100%
 
The RingArray constructor will accept any array-like object, be it an object that looks like an array, a real array, a jQuery object, a DOM NodeList etc etc. What you do with the data at the current indexed RingArray element is up to you. So an array of URLs (strings) will be fine for the RingArray.
 
jsfiddle.net/sab60wff this fiddle works fine now, url changes with controls. however, could you alter it so that the utubeFrame is a CLASS. Then i will accept it as a solution, thanks for your time so far
 
8:54 PM
Sure, change the HTML id to class and then utubeFrame = $('.utubeframe') and utubeFrame[0].href = ... instead of utubeFrame.href = ... should do it, I believe.
 
ok thanks accepted as solution, what difference does the [0] make?
so I tried this 'console.log($("a").attr("href"));' on 'random' button and it displays the same url everytime. it doesn't update it
 

last day (15 days later) »