juancabrera / react-asset-loader

React component for loading images and videos without affecting the page load speed.
MIT License
185 stars 5 forks source link

Make it smart so it will create just one video element with different sources instead of multiple video elements #2

Open juancabrera opened 9 years ago

sseppola commented 9 years ago

How do you want to specify that there are different sources of the same video? What about their types?

What do you think about something like this?

var myAssets = [
  {
    type: "video",
    assets: [
      {uri: "/static/videos/video1.mp4", type: "video/mp4; codecs=avc1.42E01E,mp4a.40.2"},
      {uri: "/static/videos/video1.webm", type: "video/webm; codecs=vp8,vorbis"}
    ]
  }
];
<LoadAssets assets={myAssets} />
juancabrera commented 9 years ago

Right now the "cool think" of asset loader is that you don't need to pass any type (like your type:"video"), it's detecting it. So I won't add the type.

I thought that maybe if there are 2 videos with different formats with the same name assume it's a video with two sources. Not sure if it's the best solution though, I feel that to do this it will add lot of code, and want to keep it small..