Search code examples
objective-ciosavassetwriter

How to assign my integer value to CMTime iOS Sdk


i want to assign my int value to CMTime type variable

i want this to code like:

CMTime frameTime;
if (i == 0 && i == 1) {
    frameTime = 0;//CMTimeMake(value, preferredTimeScale);
}
else if(i == 2) {
    frameTime = 2;
}
else {
    frameTime = 3;
}

append_ok = [adaptor appendPixelBuffer:buffer 
                  withPresentationTime:frameTime];

instead of:

int64_t value = 10000;
int32_t preferredTimeScale = 600;
frameTime = CMTimeMake(value, preferredTimeScale);

Is this possible?


Solution

  • i'm not sure if this helps you but i am using CMTime like this :

    float seeking = songDuration*[slider value];
    CMTime seekingCM = CMTimeMake(seeking, 1);
    [mainDelegate.theAudio seekToTime:seekingCM]; //mainDelegate.theAudio is avplayer
    

    the code above just creates the CMTime for me for the exact time that i want to go on the audio and on the slider..

    i hope this is what you are looking for..