19

現在のプレイ時間に 5 秒を追加するにはどうすればよいですか?
実際、これは私のコードです:

CMTime currentTime = music.currentTime;

CMTime 形式が必要なため、 CMTimeGetSeconds() を使用できません。

ご回答ありがとうございます...

編集:CMTimeの変数を設定するにはどうすればよいですか?

4

4 に答える 4

33

1 つの方法を次に示します。

CMTimeMakeWithSeconds(CMTimeGetSeconds(music.currentTime) + 5, music.currentTime.timescale);
于 2013-02-26T19:56:21.727 に答える
24

エレガントな使い方CMTimeAdd

CMTime currentTime = music.currentTime;
CMTime timeToAdd   = CMTimeMakeWithSeconds(5,1);

CMTime resultTime  = CMTimeAdd(currentTime,timeToAdd);

//then hopefully 
[music seekToTime:resultTime];

あなたの編集に:これらの方法で CMTime 構造体を作成できます

CMTimeMake
CMTimeMakeFromDictionary
CMTimeMakeWithEpoch
CMTimeMakeWithSeconds

もっと @: https://developer.apple.com/library/mac/#documentation/CoreMedia/Reference/CMTime/Reference/reference.html

于 2013-02-27T23:20:06.083 に答える