Using Titanium, what is the best method to create the following:-
- Open any window, regardless of which window/code/tab-group opened the current window
- Control audio tracks, regardless of which window/code/tab-group is currently opened (ie: Window #6 can start the audio, Window #2 can stop it)
- When the audio stops, what's the best method of controlling an element on every window, like a "Now Playing" Button
A year ago, I tried setting up the file structure in Titanium as I thought would be appropriate, but the iPhone application created multiple threads and often code could not control other components on a separate thread. So I pushed the whole application into a single file and it worked fine.
Now the application needs to grow and it really isn't friendly having all the code in a single file.
If you use a commonjs structure, then you can reuse commonjs modules as components that can control items from your app from any window/view/etc. The idea is this:
- Your audio tracks are going to be launched and controlled from your main application window.
- You're going to create a NowPlaying.js button module that will maintain control of your currently playing track
- You can then require() that module in any window and basically reuse that component anywhere
- When you interact with that button ie: stop,play,pause,etc, you'll send events back to the main app window using application event listeners that will allow you actually control the audio track.
One thing that you'll have to keep in mind is that while you navigate windows, things in your Now Playing view may change. So as you focus on each window, you'll have to check the component on that page and make sure that its up to date and displaying the correct info for whats currently playing.
Think you can help? Login to answer this question!