31 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
32 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
33 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
34 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
38 var mediacoreManager =
Cc[
"@songbirdnest.com/Songbird/Mediacore/Manager;1"]
39 .getService(
Ci.sbIMediacoreManager);
41 log(
"Testing basic event target functionality\n");
47 log(
"Test factory logic\n");
48 var factories = mediacoreManager.factories;
49 log(
"Number of factories found: " + factories.length);
51 for(let
i = 0;
i < factories.length; ++
i) {
52 let factory = factories.queryElementAt(
i,
Ci.sbIMediacoreFactory);
54 log(
"Factory name: " + factory.name);
55 log(
"Factory contract id: " + factory.contractID);
58 var
uri =
newURI(
"file:///Volumes/Aus-DATA/Media/gnb_mix3.mp3");
59 var mediacoreVotingChain = mediacoreManager.voteWithURI(uri);
61 var mediacore = mediacoreVotingChain.mediacoreChain.queryElementAt(0,
Ci.sbIMediacore);
65 if(mediacore instanceof
Ci.sbIQuickTimeMediacore) {
66 log(
"QuickTime version: " + mediacore.quickTimeVersion);
69 if(mediacore instanceof
Ci.sbIWindowsMediacore) {
70 log(
"Windows media player version: " + mediacore.windowsMediaVersion);
75 log(
"Attempting to play: " + uri.spec);
79 log(
"Attempting to seek to: " + 120000 / 1000 +
"s");
80 mediacore.position = 120000;
83 log(
"Attempting to set volume to: " + vol);
84 mediacore.volume = vol;
88 log(
"Attempting to pause.");
91 log(
"Attempting to stop.");
95 if(factories.length > 1) {
99 log(
"Going to attempt to play another file, with another core if possible.");
100 mediacore = mediacoreVotingChain.mediacoreChain.queryElementAt(index,
Ci.sbIMediacore);
103 if(mediacore instanceof
Ci.sbIQuickTimeMediacore) {
104 log(
"QuickTime version: " + mediacore.quickTimeVersion);
107 if(mediacore instanceof
Ci.sbIWindowsMediacore) {
108 log(
"Windows media player version: " + mediacore.windowsMediaVersion);
114 var uri2 =
newURI(
"file:///Users/aus/Music/fluxblog.org/fujiyamiyagi_knickerbocker.mp3");
116 log(
"Attempting to play: " + uri2.spec);
117 mediacore.uri = uri2;
120 log(
"Attempting to seek to: " + 1200 / 1000 +
"s");
121 mediacore.position = 1200;
124 log(
"Attempting to set volume to: " + vol);
125 mediacore.volume = vol;
135 this.wrappedJSObject =
this;
141 onMediacoreEvent:
function(
event) {
146 var eventIDs = [
Ci.sbIMediacoreEvent.METADATA_CHANGE,
147 Ci.sbIMediacoreEvent.URI_CHANGE,
148 Ci.sbIMediacoreEvent.DURATION_CHANGE,
149 Ci.sbIMediacoreEvent.VOLUME_CHANGE,
150 Ci.sbIMediacoreEvent.MUTE_CHANGE,
151 Ci.sbIMediacoreEvent.STREAM_FOUND,
152 Ci.sbIMediacoreEvent.BUFFERING,
153 Ci.sbIMediacoreEvent.BUFFER_UNDERRUN,
154 Ci.sbIMediacoreEvent.STREAM_START,
155 Ci.sbIMediacoreEvent.STREAM_PAUSE,
156 Ci.sbIMediacoreEvent.STREAM_END];
160 this.wrappedJSObject =
this;
170 mediaManager.addListener(listener);
171 for (index = 0; index < eventIDs.length; ++index) {
172 var
event = mediaManager.createEvent(eventIDs[index],
new dummyMediacore(),
"",
null);
173 mediaManager.dispatchEvent(
event,
false);
175 assertEqual(listener.log.length, eventIDs.length,
"event received count not equal to events sent");
176 for (index = 0; index < eventIDs.length; ++index) {
177 assertEqual(listener.log[index].type, eventIDs[index],
"Event type doesn't match event ID sent");
179 mediaManager.removeListener(listener);
function sleep(ms, suppressOutput)
sbOSDControlService prototype QueryInterface
function assertEqual(aExpected, aActual, aMessage)
function newURI(aURLString)
_getSelectedPageStyle s i