I have html5 audio player written using soundmanager2.
In my jquery I would need to get track urls and titles for my player from the link like this:
http://soundcloud.com/officialswedishhousemafia/sets/rootmusic-bandpage
or this for example:
http://gidilounge.fm/?feed=podcast
Is this possible?
I'd recommend using the SoundCloud JavaScript SDK (which incidentally includes soundManager2 for streaming support). If all you have is the set URL, you could use the resolve endpoint to get an id and a proper representation of the resource:
SC.initialize({
client_id: 'foo'
});
var set_url = "http://soundcloud.com/officialswedishhousemafia/sets/rootmusic-bandpage";
SC.get('/resolve', { url: track_url }, function(set) {
$(set.tracks).each(function(i, track) {
console.log(track.title);
});
});
That should allow you to get all the information about tracks that you need.
SoundCloud has an open API: http://developers.soundcloud.com/
Hope that's what you're looking for.
Related
I'm using Vimeo to host video files for a project however the videos can be in up to 8 languages. We are using subtitles PER VIDEO to split the languages up (1 video, 8 subtitle files).
The problem is I'm not able to find in the API docs or anywhere else if there's is a possibility of setting the language of the subtitles using the API or perhaps the iframe embed attributes.
Any help on this matter would be much appreciated. Thanks!
To all who are curious, I ended up building my own subtitle engine. The client had the subtitle files already created so using those and some clever JS parsing found online I was able to recreate subtitle functionality on my end.
Let me know if you need help with that :)
Duplicate of Vimeo force CC language
You can use the enableTextTrack function on a player initialized by the JS API provided by Vimeo:
// Select with the DOM API
var iframe = document.querySelector('iframe');
var iframePlayer = new Vimeo.Player(iframe);
player.enableTextTrack('en').then(function(track) {
// track.language = the iso code for the language
// track.kind = 'captions' or 'subtitles'
// track.label = the human-readable label
}).catch(function(error) {
switch (error.name) {
case 'InvalidTrackLanguageError':
// no track was available with the specified language
break;
case 'InvalidTrackError':
// no track was available with the specified language and kind
break;
default:
// some other error occurred
break;
}
});
More information on the github of Vimeo player JS API: https://github.com/vimeo/player.js#enabletexttracklanguage-string-kind-string-promiseobject-invalidtracklanguageerrorinvalidtrackerrorerror
is there any other way to load webaudioAPI except xmlhttprequest ??
it seems xmlhttprequest can only played with local server like "localhost/blablabla"
I want make my game can play locally without any serverside like 'file:///E:/blablabla'
thx
regards
Well, you could recode the file as a data: URL.
what is your goal when using the audio api? There are two things to use as a source. First, you can use the Source node, which you specify 192000Hz PCM. This is decoded by the .decodeAudioData as you know, from an arraybuffer. This takes a lot of time and power. A second much easier method is to use the <audio> tag. You can give this an src (even with file:///E:/blablabla), which loads pretty fast or specify it with a data-url (also much faster than the context.decodeAudioData).
Example HTML:
<audio src="E:/blablabla.mp3"></audio>
Example JS:
window.audiotag = document.getElementsByTagName('audio')[0];
function audioReady() {
window.AudioContext = window.AudioContext||window.webkitAudioContext;
context = new AudioContext();
source = context.createMediaElementSource(audiotag);
source.connect(context.destination);
audiotag.play();
}
audiotag.onload = audioReady();
This simply lets audio play from the audio tag, but when the audio tag gets connected to the sourcenode, it automatically mutes and sends it audio to the audio-api.
The frameworks i'm using are AngularJS(client-side) and Sitebricks(server-side).
I want to return a list of objects into json and make the client download that json by prompting the user where he wants to save the file.
I accept all kind of propositions.
Cheers in advance.
It sounds like you want to create the file in the browser, and save it to the user's local machine. One method is presented here, but it doesn't work in IE Javascript: Create and save file
Here's a fiddle: http://jsfiddle.net/vUdyD/
$(function() {
function exportToCsv() {
var myCsv = "Col1,Col2,Col3\nval1,val2,val3";
window.open('data:text/csv;charset=utf-8,' + escape(myCsv));
}
var button = document.getElementById('b');
button.addEventListener('click', exportToCsv);
});
You could use the HTML5 download attribute. It is not perfect and browser support
<!-- will download as "expenses.pdf" -->
Download Your Expense Report
Demo: http://davidwalsh.name/download-attribute
Support: http://caniuse.com/#feat=download
Right now I have a website that uses jPlayer to stream mp3s on. I also want to be able to add the functionality of letting SoundCloud stream directly on the player.
I know this is possible, because one of my favorite music blogs hillydilly does this. From looking at their code, I see their setup for their jPlayer has a few extra arguments, namely sc and sclink.
$(".play-music").each(function(){
myPlaylist.add({
title: $(this).attr('data-title'),
artist: $(this).attr('data-artist'),
mp3: $(this).attr('data-mp3'),
url: $(this).attr('data-url'),
sc: $(this).attr('data-sc'),
sclink: $(this).attr('data-sclink')
});
});
I tried looking through the rest of their code, but can't figure out how or where they implement sc and sclink. Any help?
If you look at their playlist they're linking to Soundcloud for the mp3 property of the track:
myPlaylist.setPlaylist([
{
title:"Close Enough ft. Noosa",
artist:"Ghost Beach",
mp3:"http://api.soundcloud.com/tracks/79031167/stream?client_id=db10c5086fe237d1718f7a5184f33b51",
url:"http://hillydilly.com/2012/12/top-20-songs/",
sc:"true"
},
{
title:"Always",
artist:"Jahan Lennon",
mp3:"http://api.soundcloud.com/tracks/80961874/stream?client_id=db10c5086fe237d1718f7a5184f33b51",
url:"http://hillydilly.com/2012/12/top-20-songs/",
sc:"true"
}
HTML5 'streams' are really just MP3s you currently can't protect them like you can with Flash, Silverlight, Quicktime etc. If you open one of those links directly (like http://api.soundcloud.com/tracks/79031167/stream?client_id=db10c5086fe237d1718f7a5184f33b51) it'll download the MP3. So I'm guessing it you set it up the same way it should just work.
If you open up Chrome and its Network inspector (in dev tools: View > Developer > Developer Tools, then click Network) and click next on Hilly's player you can see the track loading in the background.
Actually kreek's answer is only half the story.
If you want to stream soundcloud songs, you first of all need to register your website on the developer page developers.soundcloud.com.
Then use their super cool API with your own key. You can either load the json into your php and generate links there or you load the information with jquery $.getJSON.
When streaming sounds from soundcloud you also want to be sure to properly attribute. The people from soundcloud are very generous to let us use their database like that.
//sorry for the bad links (no credits)
How do I use external JSON...?
http://api.jquery.com/jQuery.getJSON/
http://developers.soundcloud.com/docs/api/buttons-logos
I'm trying to get current browser url. I have already tried with External Call, and it didn't work. And with loaderInfo.url I receive the current SWF url.
Give this a go:
import flash.external.ExternalInterface;
var url:String = ExternalInterface.call("window.location.href.toString");
if (url) textfield.text = url;
should do the trick.
There are a couple of ways to solve this problem, however all of them involve the use of JavaScript to query the browser directly.
My preferred way to solve this problem would be to provide the URL via a flashVar property, direct from the embed code (personally, I would reccomend using SWFObject to make this easier); don't forget you will need to URL Encode it to avoid markup issues.
var flashvars = {
browserURL: escape(location.href)
};
swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0", "expressInstall.swf", flashvars);
Now you will be able to access the Browser URL via the loaderInfo object:
trace(stage.loaderInfo.parameters["browserURL"]);
note that this will only work if you have control of generated HTML for your SWF file - if users are going to be grabbing the SWF and writing their own embed HTML, it's not going to work.
If you don't have control of the flash embed HTML, then you will need to get flash to query the browser at runtime using the ExternalInterface class; other people have suggested the use of "window.location.href.toString" however this can prove problematic in IE6, I find the following works reliably across all browsers
const browserURL : String = ExternalInterface.call("eval", "window.location.href");
Note that in order for this to work, you will need to grant JavaScript access to your Flash movie, this is done, again, via the HTML embed code and the allowScriptAccess param
var url:String = loaderInfo.loaderURL;
seems to work too.
I would try passing the required info in as a flashvar. Not the best out of the box solution I know, but it will work.
Flash: FlashVars in AS3
i think its posible to use the external interface an do it with javascript window.location
I have been using flash for a long time and never noticed this one. It only gives the domain though for security. It does work through loaded swfs as well. Not sure about iframes.
Security.pageDomain