Author: fejj
Date: 2007-08-23 15:36:50 -0400 (Thu, 23 Aug 2007)
New Revision: 84742
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/media.cpp
Log:
2007-08-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
* media.cpp (DownloaderComplete): If we fail to open, emit the
MediaFailedEvent and set some default values.
(OnPropertyChanged): Don't StopLoader() here, do that all in
SetSource (since SetSource needs to do it anyway).
(SetSource): Call StopLoader() here and close the MediaPlayer,
etc.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-08-23 19:34:35 UTC (rev 84741)
+++ trunk/moon/src/ChangeLog 2007-08-23 19:36:50 UTC (rev 84742)
@@ -1,3 +1,12 @@
+2007-08-23 Jeffrey Stedfast <[EMAIL PROTECTED]>
+
+ * media.cpp (DownloaderComplete): If we fail to open, emit the
+ MediaFailedEvent and set some default values.
+ (OnPropertyChanged): Don't StopLoader() here, do that all in
+ SetSource (since SetSource needs to do it anyway).
+ (SetSource): Call StopLoader() here and close the MediaPlayer,
+ etc.
+
2007-08-23 Jackson Harper <[EMAIL PROTECTED]>
* runtime.cpp|h: Make Resize use our event system (so the plugin
Modified: trunk/moon/src/media.cpp
===================================================================
--- trunk/moon/src/media.cpp 2007-08-23 19:34:35 UTC (rev 84741)
+++ trunk/moon/src/media.cpp 2007-08-23 19:36:50 UTC (rev 84742)
@@ -282,22 +282,30 @@
// FIXME: specify which audio stream index the player should use
- if (mplayer->Open (filename)) {
- printf ("video succesfully opened\n");
+ if (!mplayer->Open (filename)) {
+ media_element_set_can_seek (this, false);
+ media_element_set_can_pause (this, false);
+ media_element_set_audio_stream_count (this, 0);
+ media_element_set_natural_duration (this, Duration (0));
+ media_element_set_natural_video_height (this, 0);
+ media_element_set_natural_video_width (this, 0);
- media_element_set_can_seek (this, mplayer->CanSeek ());
- media_element_set_can_pause (this, mplayer->CanPause ());
- media_element_set_audio_stream_count (this,
mplayer->GetAudioStreamCount ());
- media_element_set_natural_duration (this, Duration
(mplayer->Duration () * TIMESPANTICKS_IN_SECOND / 1000));
- media_element_set_natural_video_height (this, mplayer->height);
- media_element_set_natural_video_width (this, mplayer->width);
-
- media_element_set_current_state (this, "Buffering");
- } else {
media_element_set_current_state (this, "Error");
- printf ("video failed to open\n");
+ Emit (MediaFailedEvent);
+ return;
}
+ printf ("video succesfully opened\n");
+
+ media_element_set_can_seek (this, mplayer->CanSeek ());
+ media_element_set_can_pause (this, mplayer->CanPause ());
+ media_element_set_audio_stream_count (this,
mplayer->GetAudioStreamCount ());
+ media_element_set_natural_duration (this, Duration (mplayer->Duration
() * TIMESPANTICKS_IN_SECOND / 1000));
+ media_element_set_natural_video_height (this, mplayer->height);
+ media_element_set_natural_video_width (this, mplayer->width);
+
+ media_element_set_current_state (this, "Buffering");
+
Invalidate ();
// FIXME: if the Source finishes downloading before the xaml
@@ -322,8 +330,18 @@
dl->ref ();
if (downloader) {
+ // Abort the current downloader
+ StopLoader ();
+
+ // Abort the current advance_frame timeout
+ if (timeout_id != 0) {
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+ }
+
+ // Close the media stream
+ mplayer->Close ();
media_element_set_current_state (this, "Closed");
- downloader->unref ();
}
downloader = (Downloader *) dl;
@@ -442,21 +460,9 @@
MediaElement::OnPropertyChanged (DependencyProperty *prop)
{
if (prop == MediaBase::SourceProperty) {
- StopLoader ();
-
char *uri = media_base_get_source (this);
+ Downloader *dl = new Downloader ();
- if (timeout_id != 0) {
- media_element_set_current_state (this, "Closed");
- g_source_remove (timeout_id);
- timeout_id = 0;
- }
-
- mplayer->Stop ();
-
- media_element_set_current_state (this, "Opening");
-
- Downloader *dl = new Downloader ();
downloader_open (dl, "GET", uri);
SetSource (dl, "");
} else if (prop == MediaElement::AudioStreamCountProperty) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches