I’ve ran into a weird problem while trying to send a JSON command to my company’s flash player. Basically, i am unable to pass a playlist to this player – nothing happens – using the following command:
player.sendEvent("LOAD_PLAYLIST", json_str);
but the weirdest part is that if I print the entire command using Firebug’s console.log, copy it and paste it into the code (thus hardcoding the playlist), everything works like a charm.
For instance, the following code:
player.sendEvent("LOAD_PLAYLIST", "{\"streams\": [{\"src\": \"rtmp:\/\/xxx.xxx.xx:80\/redirectvodxxx\/nas2.share\/h264\/512x384\/progname1\/prog_1_20110804.mp4\"},{\"src\": \"rtmp:\/\/xxx.xxx.xx:80\/redirectvodxxx\/nas2.share\/h264\/512x384\/progname2\/prog_2_20110804.mp4\"},{\"src\": \"rtmp:\/\/xxx.xxx.xx:80\/redirectvodxxx\/nas2.share\/h264\/512x384\/progname3\/prog_3_20110804.mp4\"}]}");
was obtained using
console.log('[loadNewListofContents] playing the following content list: player.sendEvent(\"LOAD_PLAYLIST\", ' + json_str.toString() + ');');
and if i hardcode it, it works!
I’ve tried all the toString() tricks I can think of (ex: json_str.toString(), ‘”‘ + json_str.toString() + ‘”‘, etc…) but so far no such luck.
Any ideas?
Thanks in advance!
the code you posted
Is a string that is using “\” to escape quotes AS3 has known issues with that
Just pass the JavaScript object straight to the SWf.
This code is untested but it should give you an idea