I need to get an absolute file path into the native AIR browser. I’ve gotten the value of it,and the alert in my function called by the AIR app works fine, but can’t seem to make it do anything.
How do I make siteRoot available to my $(document).ready function?
function calledFromAS(test)
{
siteRoot = test;
alert(siteRoot);
}
$(document).ready(function(){
alert(siteRoot);
})
EDIT: much larger code snippet
from my Flex project (where calledFromAs() is called):
var filePath = File.applicationDirectory.nativePath;;
function init():void {
html.htmlLoader.window.calledFromAS(filePath);
}
From the js file which builds the player and playlists:
$(document).ready(function(){
//alert(siteRoot);
// instantiate the player so that the playlist always exists
var myPlaylist = new jPlayerPlaylist({
jPlayer: "#jquery_jplayer_N",
cssSelectorAncestor: "#jp_container_N"
}, [
{
mp3:"http://www.jplayer.org/audio/mp3/TSP-01-Cro_magnon_man.mp3",
oga:"http://www.jplayer.org/audio/ogg/TSP-01-Cro_magnon_man.ogg"
//poster: "http://www.jplayer.org/audio/poster/The_Stark_Palace_640x360.png"
}
], {
playlistOptions: {
enableRemoveControls: true
},
swfPath: "js",
supplied: "flv"
});
//hide the player, display homepage content when user clicks home
$('#home').click(function(){
//show home page content
$('#homeContent').show();
// remove hover state from all buttons but this one
$(".button").removeClass("on");
$(this).addClass("on");
$('#player_container').hide();
})
//############## begin full video player ############# //
// instantiate player for full video content. no playlist
$('#fullVideo').click(function() {
//show current video title before video is played
$('#videoTitle').empty();
$('#videoTitle').append("Full Video")
// remove hover state from all buttons but this one
$(".button").removeClass("on");
$(this).addClass("on");
//hide the home content, show the player instead
$('#homeContent').hide();
$("#player_container").show().addClass("player_container_1").removeClass("player_container_2");
//set the playlist
myPlaylist.setPlaylist([
{
title:"Full Video",
//m4v:"http://dev.brandgnumedia.com/html5video/jplayer/vids/Forest_with_new_slides_NoQA_v2_011712_edits.mp4",
flv: test + "jplayer/vids/Forest_with_new_slides_NoQA_v2_011712_edits_1.flv"
}
], {
});
//hide the playlist
$('.jp-playlist').hide();
});
By the looks of it, your Flash app needs to tell JS the path to your files.
To do this, you have to move your player script outside the
.ready()and in to a separate function. then, have that function called from the AS script with your path passed.however, it’s risky to assume that if your flash has loaded, all the DOM is loaded. you need to have a function in flash to be called from
.ready()to tell flash that all of the DOM has loaded, and from there, have flash call the function above.