33 #include <nsIWritablePropertyBag2.h>
35 #include <nsComponentManagerUtils.h>
45 static PRLogModuleInfo* gBaseMediacorePlaybackControl = nsnull;
46 #define TRACE(args) PR_LOG(gBaseMediacorePlaybackControl , PR_LOG_DEBUG, args)
47 #define LOG(args) PR_LOG(gBaseMediacorePlaybackControl , PR_LOG_WARN, args)
49 #define __FUNCTION__ __PRETTY_FUNCTION__
67 if (!gBaseMediacorePlaybackControl)
68 gBaseMediacorePlaybackControl= PR_NewLogModule(
"sbBaseMediacorePlaybackControl");
71 TRACE((
"%s[%p]", __FUNCTION__,
this));
76 TRACE((
"%s[%p]", __FUNCTION__,
this));
81 nsAutoMonitor::DestroyMonitor(
mMonitor);
88 TRACE((
"%s[%p]", __FUNCTION__,
this));
90 mMonitor = nsAutoMonitor::NewMonitor(
"sbBaseMediacorePlaybackControl::mMonitor");
91 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_OUT_OF_MEMORY);
97 sbBaseMediacorePlaybackControl::GetUri(nsIURI * *aUri)
99 TRACE((
"%s[%p]", __FUNCTION__,
this));
100 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
101 NS_ENSURE_ARG_POINTER(aUri);
104 NS_IF_ADDREF(*aUri =
mUri);
110 sbBaseMediacorePlaybackControl::SetUri(nsIURI * aUri)
112 TRACE((
"%s[%p]", __FUNCTION__,
this));
113 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
114 NS_ENSURE_ARG_POINTER(aUri);
117 NS_ENSURE_SUCCESS(rv, rv);
126 sbBaseMediacorePlaybackControl::GetPosition(PRUint64 *aPosition)
128 TRACE((
"%s[%p]", __FUNCTION__,
this));
129 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
130 NS_ENSURE_ARG_POINTER(aPosition);
143 sbBaseMediacorePlaybackControl::SetPosition(PRUint64 aPosition)
145 TRACE((
"%s[%p] (%llu)", __FUNCTION__,
this, aPosition));
146 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
149 NS_ENSURE_SUCCESS(rv, rv);
158 sbBaseMediacorePlaybackControl::Seek(PRUint64 aPosition, PRUint32 aFlags)
160 TRACE((
"%s[%p] (%llu, %llu)", __FUNCTION__,
this, aPosition, aFlags));
161 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
163 nsresult rv =
OnSeek(aPosition, aFlags);
164 NS_ENSURE_SUCCESS(rv, rv);
167 NS_ENSURE_SUCCESS(rv, rv);
176 sbBaseMediacorePlaybackControl::GetDuration(PRUint64 *aDuration)
178 TRACE((
"%s[%p]", __FUNCTION__,
this));
179 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
180 NS_ENSURE_ARG_POINTER(aDuration);
193 sbBaseMediacorePlaybackControl::GetIsPlayingAudio(PRBool *aIsPlayingAudio)
195 TRACE((
"%s[%p]", __FUNCTION__,
this));
196 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
197 NS_ENSURE_ARG_POINTER(aIsPlayingAudio);
203 *aIsPlayingAudio = PR_FALSE;
210 sbBaseMediacorePlaybackControl::GetIsPlayingVideo(PRBool *aIsPlayingVideo)
212 TRACE((
"%s[%p]", __FUNCTION__,
this));
213 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
214 NS_ENSURE_ARG_POINTER(aIsPlayingVideo);
220 *aIsPlayingVideo = PR_FALSE;
227 sbBaseMediacorePlaybackControl::Play()
229 TRACE((
"%s[%p]", __FUNCTION__,
this));
230 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
234 NS_ENSURE_SUCCESS(rv, rv);
241 sbBaseMediacorePlaybackControl::Pause()
243 TRACE((
"%s[%p]", __FUNCTION__,
this));
244 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
248 NS_ENSURE_SUCCESS(rv, rv);
255 sbBaseMediacorePlaybackControl::Stop()
257 TRACE((
"%s[%p]", __FUNCTION__,
this));
258 NS_ENSURE_TRUE(
mMonitor, NS_ERROR_NOT_INITIALIZED);
262 NS_ENSURE_SUCCESS(rv, rv);
276 return NS_ERROR_NOT_IMPLEMENTED;
288 return NS_ERROR_NOT_IMPLEMENTED;
298 return NS_ERROR_NOT_IMPLEMENTED;
308 return NS_ERROR_NOT_IMPLEMENTED;
319 return NS_ERROR_NOT_IMPLEMENTED;
329 return NS_ERROR_NOT_IMPLEMENTED;
339 return NS_ERROR_NOT_IMPLEMENTED;
359 return NS_ERROR_NOT_IMPLEMENTED;
379 return NS_ERROR_NOT_IMPLEMENTED;
405 return NS_ERROR_NOT_IMPLEMENTED;
429 TRACE((
"%s[%p] (%08x)", __FUNCTION__,
this, aType));
434 nsCOMPtr<sbIMediacore> core =
437 nsCOMPtr<nsIWritablePropertyBag2> bag =
438 do_CreateInstance(
"@mozilla.org/hash-property-bag;1", &rv);
439 NS_ENSURE_SUCCESS(rv, rv);
444 rv = GetPosition(&number);
445 if (NS_SUCCEEDED(rv)) {
446 rv = bag->SetPropertyAsUint64(NS_LITERAL_STRING(
"position"), number);
447 NS_ENSURE_SUCCESS(rv, rv);
454 rv = GetPosition(&number);
455 if (NS_SUCCEEDED(rv)) {
456 rv = bag->SetPropertyAsUint64(NS_LITERAL_STRING(
"position"), number);
457 NS_ENSURE_SUCCESS(rv, rv);
460 rv = GetDuration(&number);
461 if (NS_SUCCEEDED(rv)) {
462 rv = bag->SetPropertyAsUint64(NS_LITERAL_STRING(
"duration"), number);
463 NS_ENSURE_SUCCESS(rv, rv);
466 rv = bag->SetPropertyAsInterface(NS_LITERAL_STRING(
"uri"),
mUri);
467 NS_ENSURE_SUCCESS(rv, rv);
472 NS_ENSURE_SUCCESS(rv, rv);
474 nsCOMPtr<sbIMediacoreEvent>
event;
479 getter_AddRefs(event));
480 NS_ENSURE_SUCCESS(rv, rv);
482 rv = DispatchEvent(event, PR_TRUE, nsnull);
Songbird Variant Utility Definitions.