title: Stream HLS on safari using MediaSource api
body: <p>I want to stream HLS fragments using media source extension. I have tried the same using mpeg-dash fragments (generated using MP4Box) and media source extension. </p>
  
  <pre><code>var mediaSource = new window.MediaSource();
  mediaSource.addEventListener('sourceopen', _onSourceOpen);
  $('video').attr('src', URL.createObjectURL(self.mediaSource));
  
  function _onSourceOpen() {
      sourceBuffer = mediaSource.addSourceBuffer('video/mp4; codecs="avc1.64000d,mp4a.40.2"');
  }
  
  function _onFragmentDataLoad(data) {
      sourceBuffer.appendBuffer(data);
  }
  </code></pre>
  
  <p>It plays smoothly on chrome, Windows 8 IE, android chrome. It also on works on safari but it doesn't get total duration of media. So I tried same with HLS fragments on safari. Produced HLS data has <code>.m3u8</code> file and other <code>.ts</code> fragments. When I assign .m3u8 file as source to video element:</p>
  
  <pre><code>$('video').attr('src', 'filename.m3u8');
  </code></pre>
  
  <p>things work like charm. But then I loose the control on transport. To have complete control on transport and responsive resolution change, I tried putting <code>.ts</code> fragments one by one into initialised <code>sourcebuffer</code>. It fails badly in safari. But same HLS fragments play well with <code>exo player</code>. My questions are:
  1. How to achieve HLS streaming on safari using Media Source Extension.
  2. As HLS generation doesn't produce any <code>init</code> fragment unlike dash generation, how does media player understand duration and other metadata?
  3. How to get the codec of this HLS? Or there is any codec that is by default supported by safari and can be used here?</p>
  
  <p>Thanks.</p>