0
votes

Hi its a simple question to a hard problem (for me so far anyway)

i dont consider myself to be a beginner programmer but for the love of god I cannot seem to be able to figure this one out.... I currently have a problem related to updating a uiimageview.. its not being updated when my slider moves left and right.. it does slow the application down a little bit when i drag it which tells me there are processes happening and tells me they are connected correctly the itnerface with their methods.. whats happening or what im doing at the moment is trying to retrieve image data for a specific frame specified by time to then be able to select it as a thumbnail depending on the position of the uislider. so its a manual thumbnail picker.

I have tried many things both by connecting it through interface builder and by doing it programatically.

this is what i have one so far:

.h file

the dot h file

.m file

the dot m file

the slider method for sliderValueChanged which gets called

slider method

and finally my class method that i use to help retrieve a thumbnail image returning nsdata... passing in a video and a specified time position. 

class methods to retrieve thumbnail

I have read here on stackoverflow that updating a uiimageview can cause memory leaks if updated regularly since it caches images.. and to use [UIImage imageWithData:] instead to avoid any leaks etc. so i have implemented this in my code yet my thumbnail view still fails to load the images based on the slider's position. (the slider is created to have the min and max values set from 0 - to the duration of the video so that the slider can only ever have a value that can correctly pick a time frame in the video in question)

If anyone could guide me in how i could fix this problem.. it is beyond me for hours now! i appreciate the help. thank you

1

1 Answers

0
votes

I realised what was happening here... the slider values i had passed into my method werent appropriate for what i required.

in the class method it says CMTimeMake(value 1, value 2).. and after doing some research i understood how it worked.

basically there is a time interval you specify in value 2 in my case it was 60.. based on some code i copied.. whatever you substitute value 1 for becomes a part of the time interval.. They are a numerator and denominator, so 1 /60 equals 1 60th of a second 2/60 is equal to the time position of 2 60th of a second... if i wanted 3 seconds i would need to do 60*3 = 180 so

180/60 equals 180 60th of a second which equates to 3 seconds in total... so because my slider values were mapped to the duration of the video which the maximum was 15 seconds... the higest time frame i could get using the code i wrote in my question... i could only get the 15 60th of a second. which time frame wise not really a difference between the 1st 60th of a second hence the reason why i could not see the uimageview being updated...

so to correct this i multiplied my slider values by 60 so that each value that gets changed because they were mapped to seconds.. i multiplied by 60 .. and of course the image updated like a charm. however now i need to figure out how to speed up this process since at the moment it seems synchronous as it lags the interface greatly