简体   繁体   中英

Is it possible to control a streamer from an external file?

I have a radio app that has a play button on one tab, another tab has a list of news items in a table row. Then if a news item is clicked, I am moving AWAY from my app.js and into an external js. Here I have a news story and a play button also which has commentary on the story. What I need to do is share data between the pages which I think I have sorted (correct me if I'm wrong) using the following code:

//in my app.js

var yourArray = [streamer.volume, streamer.STATE_PLAYING];
 w.passedArray = yourArray;

//in my external.js
Titanium.UI.currentWindow.passedArray[0];
Titanium.UI.currentWindow.passedArray[1];

in order to determine if the streamer from the main tab is in a 'playing' state and if it is to turn down the volume while playing the news item on the external.js and when this mp3 file is finished streaming to turn back up the volume on the main page's streamer. I jope I have been clear. Any help appreciated .

Here you go method of passing array between windows in titanium.

Suppose it is app.js

var myarray = ["one", "two", "three"];

var win = Titanium.UI.createWindow({  
    title:'Test',
    url:'win.js',
    myarray:myarray
});
win.open();

and suppose it is win.js

var win = Titanium.UI.currentWindow;
var myarray = win.myarray;
Titanium.API.info(myarray.length); //oddly this outputs '3'
Titanium.API.info(myarray[1]);

thanks

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM