【问题标题】:AVPlayer current time is not workingAVPlayer 当前时间不起作用
【发布时间】:2012-01-16 13:24:01
【问题描述】:

好的。 AvPlayer 非常适合流式音频。在我的应用程序中,我有 UISlider 显示正在播放的歌曲的当前秒数。现在我正在尝试使用 UISlider 进行音频搜索。

这里是代码

-(IBAction)slide{
Float64 curSec = mySlider.value;
int32_t tScale = 600;
CMTime mySec = CMTimeMakeWithSeconds(curSec, tScale); 
player.currentTime = mySec;     <- error is here

NSLog(@"%f",mySlider.value);
}

错误是“需要使用属性分配语法分配给对象的 Setter 方法” 在 .h 文件中,我有 AVPlayer *player;和@property(非原子,保留)AVPlayer *player。同样在 .m 中,我有 @synthesize 播放器; 那么有什么问题呢?谢谢!

【问题讨论】:

    标签: iphone uislider avplayer


    【解决方案1】:

    根据doc,在我看来,您必须使用seekToTime: 方法而不是直接将时间设置为currentTime 属性。

    【讨论】:

      【解决方案2】:
      float second = 30.0;
      CMTime time = CMTimeMake(second, 1);
      [player seekToTime:time];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多