Better way to do skip to previous with AVQueuePlayer?

后端 未结 6 1146
难免孤独
难免孤独 2020-12-28 18:29

I am using an AVQueuePlayer in my app. I have a two swipe gestures to skip to next and skip to previous avplayeritems. Right now to do skip to next I am just ca

6条回答
  •  余生分开走
    2020-12-28 19:04

    does the queue handle more than one skip forward smoothly? if so, you could constantly re-insert the previous video back into the queue at index n+2. when the user wishes to play the previous track, you would skip forward twice.

    if playing from track A to F without any skips, the pattern would look like this:

    A B C D E F
    B C D E F
    
    // re-insert A after next track
    B C A D E F
    C A D E F
    
    // remove A then re-insert B
    C D E F
    C D B E F
    D B E F
    
    // remove B then re-insert C
    D E F
    D E C F
    E C F
    
    // remove C then re-insert D
    E F
    E F D
    F D
    
    // remove D then re-insert E
    F
    FE
    

    using this pattern you could only smoothly skip backwards once, but it could be modified to allow more.

    definitely not an ideal solution, but may work!

提交回复
热议问题