PDA

View Full Version : Video Player as OOP project


Flash Gordon
08-30-2007, 11:33 PM
Hi Guys,

I'm okay with code, so I'm not asking about that. However, I'd like to get a little help with coming up with a OOP structure for a video player; you know, just the standard youtube player.

From what I've learn so far I can rule out the use of several patterns:
Factory - doesn't seem to be any need for a factory
Adapter - I'm creating the code from scratch so no need.
Iterator - I won't be storing any list of data, and if I do it will be xml
Composite - I wont be having grouping of videos with sub videos so that is out.
State - while there will be different states of the player (playing, paused), i don't think this pattern will be used
Facade - i could use it, but i think it is over kill
Decorator - i don't see how right now


So that leaves me with:
Observer - this is built into the way flash event handling
Strategy - maybe?
Command - eh.....


But I also want to keep in mind (and what I haven't in the the past) is "A class should have only one reason to change" e.g. 1 class 1 job.

Could I get some help how to make a OO video player
Cheers
:)

Flash Gordon
09-01-2007, 05:11 AM
I've just started reading about MVC, and that seems like the perfect design. Though I'm up for discussion.......

Flash Gordon
09-03-2007, 07:00 AM
Well....i think I'll do it 2 ways for fun:

State Pattern
MVC

m23
10-22-2007, 06:33 AM
I am working on the same project. How has it been going?

I definitely see using the state pattern, but I'm not sure exactly how it fits into an mvc pattern. For example, I'm thinking that the model would be the context in the state pattern, and that the controllers would be the states.

The view would be the user interface. Would each ui element be a view? I'm working on the code but I'm not sure how it will all work in the end. Is there a pattern for the views calling the controllers? Or do you just hard code that in, since you're dealing with ui elements using flash event handling?

Also, I'm looking at using the Observer pattern as well. The model would be the subject in the observer pattern, with the views being the observers.

Flash Gordon
10-22-2007, 07:39 AM
on the adobe site, they have a tutorial how to do it as a state pattern. It looked pretty stupid to me. The MVC turned out great.

m23
10-23-2007, 06:11 PM
So which patterns did you use?

Also, why did the state pattern not work for you? (I'm not looking to debate any particular pattern, just curious about your experience.)

Flash Gordon
10-23-2007, 07:03 PM
Adobe State Pattern Tutorial (http://www.adobe.com/devnet/flashmediaserver/articles/video_state_machine_as3.html)

I used MVC. State Pattern doesn't make sense to me for this. There really are no "states" for a video player.

m23
10-23-2007, 07:13 PM
I'm guess I'm looking for various code examples. So you used an mvc framework like this? Colin Moock provides some class files for implementing mvc.

http://www.adobe.com/devnet/flash/articles/mv_controller.html

If you could post any example code, I would greatly appreciate it!

Can I see your video player online as well? Let's see your handy work :)

Flash Gordon
10-23-2007, 08:09 PM
The video player is propritary. I can't give you any help there, other than just guiding you.

Your best best is just to start coding it in several pattern and find the limitations yourself. For me and what I wanted, MVC made the most sense. You may have different needs.

m23
10-23-2007, 10:10 PM
Not looking for anything for free. Just some code examples. So I didn't mean to imply that. I couldn't post any code from actual production projects either. :p

If anyone would like to post some examples of design patterns they have used and found suited to a video player, I would appreciate it.

For example, to me, in the mvc pattern, it makes sense to use the observer pattern between the view and the model, with the model being the subject and view being the observer. So, within mvc, there are multiple design patterns used to implement mvc. That's my understanding. I working this out in uml and I would be glad to post selected examples later.