Trying to support multiple video providers.

  1. Internal video provider (User uploads video on app server and application plays it)
  2. Youtube provider (Gets everything from youtube and plays it by using embeded youtube video)
  3. Vimeo
  4. Some other provider

UI will enable user to select it's provider when selecting some video. Did anybody implemented something similar and do you recommend to use Provider model or Repository pattern for that?

有帮助吗?

解决方案

It sounds like you are trying to force a pattern into your project.

Me personally would make a VideoManager class that uses a strategy pattern to call a provider. The VideoManager would have functions like:

  1. GetVideo(string name)
  2. GetVideos()
  3. Search(string text)
  4. UploadVideo(File file)

these functions would call the appropiate Provider, DAL or whatever you call it, that does the fetching of data. The you can write different video provider strategies.

其他提示

For playing videos to make it in common way use Provider model, or actually provider model is Strategy pattern (or similar to Factory method). You can use one of them to play videos in common ways.

Use repository pattern with unit of work for data access or when it good for you to access videos storage.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top