         }
     }
 */
+    func handleVideoEnd(videoPlayer:AVPlayer) {
+        if self.delegate != nil && self.delegate!.shouldRepeat(self) {
+            videoPlayer.seek(to: CMTime(seconds:Double(self.videoStart), preferredTimescale: 600))
+            videoPlayer.play()
+        } else {
+            self.fNeedRewind = true
+            if self.fPlaying {
+                self.fPlaying = false
+                self.delegate.didFinishPlaying(self, completed:true)
+            }
+        }
+    }
+    
     func isVideoElement() -> Bool {
         if self.videoPlayer != nil {
             return true

                    }
                    videoPlayer.play()
                    self.fNeedRewind = false
                }
            }
        }

    private var pendingOffset:CGFloat?
    private var fPlaying = false
    private var videoStart = CGFloat(0.0)
    private var videoDuration:CGFloat?

    // Sprite Element Specific
    private var spriteLayer:CALayer?
