AVPlayer.currentTime()返回0是因为需要先播放视频才能获取当前时间。在开始播放视频之前,currentTime的值将为0。因此,您需要等待视频准备好,然后开始播放才能获取非零值。示例代码如下:swiftimport AVFoundationlet player = AVPlayer(url: videoUrl)player.play()// Wait for the player to be ready before getting the current timeif player.currentItem?.status == .readyToPlay { let currentTime = player.currentTime().seconds // Do something with the current time}