Matthieu Weber wrote:
> I definitely need a lecture about event handling in Freevo (if someone
> is kind enough to explain this to me).

I will try.

Each Item handles an event and/or sends it to it's parent. It's done
by calling the Item.eventhandler() who checks 'if parent' and calls
the parent eventhandler.

> When playing movies (stored on the HDD, so no media-not-found problem
> involved here) from a FXD file, I have the following structure:
>
> DirItem (where from I start the playing)
>   VideoItem_A (represents the thing I want to play)
>     VideoItem_B (variant[0])
>       VideoItem_C (file 1 in the variant)
>       VideoItem_D (file 2 in the variant)
>
> I designed the FXD so that "file 1" does not exist. So when the
> VideoItem_C calls self.player.play(), the player returns an error
> message, and VideoItem_C calls rc.post_event(PLAY_END).
>
> This event is seen in the enventhandler of VideoItem_A, which passes it
> to its parent (DirItem). 

VideoItem_C can't play the file, the player itself return an error.

|  error = self.player.play(mplayer_options, self)
|
|  if error:
|      AlertBox(text=error).show()
|      rc.post_event(PLAY_END)

We are in the menu now. The menu code works like this: if we have an
event, send it to the selected item. This item will pass it to it's
parent and so on. The menu doesn't know about VideoItem_B to
VideoItem_D, there is only VideoItem_A. This one gets the event,
doesn't consume it and it goes up to the DirItem.

> But when the playing works properly (i.e. the
> filename does exist), the player returns also a PLAY_END, but this one
> is caught by VideoItem_B (which then starts to play VideoItem_D, which
> is exactly what I expect).
>
> So the big question is: who decides what eventhandler receives what
> event? howcome the the PLAY_END is received by A and not by B in case
> of an error?

Now everything works great. Mplayer quits. Now the menu is not active,
the event goes to mplayer.eventhandler (rc.app(...) is used to the
eventhandler, rc.app(None) sets it to menu). This handler gives it to
his item (self.item). This is VideoItem_C:

|  # PLAY_END: do have have to play another file?
|  if self.subitems:
|      if event == PLAY_END:
|

no, VideoItem_C has no subitems, so it's passed to it's parent. This
is VideoItem_B. This one has subitems and the event is used to start
VideoItem_D.

> Thanks for all help you can bring me.

Does this help?


Dischi

-- 
My software never has bugs. It just develops random features.


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Freevo-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to