title: AVPlayer seeking a HLS Audio Stream
body: <p>I'm using AVPlayer to stream a hls stream. <strong>The issue</strong> I'm having is that I'm incapable of seeking to a time. </p>
  
  <p>The seeking logic works fine with the <a href="http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_16x9/bipbop_16x9_variant.m3u8" rel="nofollow">Apple's example hls stream</a>. It also works fine with the non-hls stream I have but we wanted to use hls on this project.</p>
  
  <p><strong>So my belief</strong> is that problem is more likely with our stream and how AVPlayer handles it. </p>
  
  <p>The playlist.m3u8</p>
  
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=61378,CODECS="mp4a.40.34"
  chunklist_w1105403169.m3u8
  </code></pre>
  
  <p>The chunklist_w1105403169.m3u8</p>
  
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-ALLOW-CACHE:NO
  #EXT-X-TARGETDURATION:11
  #EXT-X-MEDIA-SEQUENCE:5015
  #EXTINF:10.028,
  media_w1105403169_5015.mp3
  #EXTINF:10.036,
  media_w1105403169_5016.mp3
  #EXTINF:10.027,
  media_w1105403169_5017.mp3
  </code></pre>
  
  <p>I have checked the stream using mediastreamvalidator and I do get:</p>
  
  <pre><code>Warning: (0:-16230) #EXT-X-ALLOW-CACHE should only be in master playlist
  </code></pre>
  
  <p>but its my understanding Apple ignores this flag. </p>
  
  <p>I've no control over the stream but can request changes.</p>
  
  <p><strong>A cut down version of my implementation:</strong></p>
  
  <p>Setup of the player     </p>
  
  <pre><code>AVPlayer *player = [[AVPlayer alloc] initWithURL:url];
  </code></pre>
  
  <p>Seeking back by x seconds</p>
  
  <pre><code>- (void)trySeekBackBy:(NSTimeInterval )seconds
       CMTime minus = CMTimeMakeWithSeconds(seconds, 1);
       CMTime time = CMTimeSubtract(self.currentTime, minus);
  
       //check that time is within the seek able range. 
       if ([self canSeekToTime:time]) {
             //I normally just seekToTime: 
            [self seekToTime:time toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
       }
     / /else work down till we can find a range we can seek to 
   }
  </code></pre>