I am trying to merge an audio in video but this custom audio does not necessarily from the beginning. The user listens for a music and then if the user feels like want to start the video recording, the user will tap on a button that starts the video recording while the music is playing.
So the user could start after 20 or 32 seconds after the audio started.
I have no problem in merging, but my problem is understanding how to set the CMTimeRange.Start using CMTime for my audio background.
The Start time value is a .NET's TimeSpan, now for example the user started after 32 seconds
var startTime = new TimeSpan(0,0,32);
or the user started after 53 seconds and then starts the video recording.
how do you translate this to CMTime?
First, we get the seconds From TimeSpan by using
TimeSpan span;
double time = span.TotalSeconds
Then ,we have to understand CMTime and how to translate float values to it.
Here you can refer to .
CMTime has a value and a timescale field, and time = value/timescale .
Related
Scenario:
I have a keynote presentation of 32 slides. The first slide contains a video playing in a loop. The video has a length of 3m 24s. The presentation will be displayed on an iPad connected to a TV during a trade show in kiosk mode.
Requirement:
The presentation should restart after a fixed period of minutes of inactivity. In keynote, I can only enter full minutes, not seconds
Issue:
The presentation also restarts while being on the first slide. Since the video length does not match the inactivity interval, the video does not loop continously, but gets restarted somewhere in the process of playing.
Question(s):
Is there anywany to change the period of inactivity to respect seconds as well?
Is it possible to have the presentation being restarted, ONLY if it is NOT on the first slide? Maybe with AppleScript?
For a Mac app I'm trying to use the MPNowPlayingInfoCenter with playback controls and track info.
I'm using the MPMediaItemPropertyPlaybackDuration property to set the track duration, with the number of seconds as NSNumber wrapped value.
Tracks over 1 hour do not show the full duration and roll over at 59:59.
Is there any way to make items in the control center show their full duration & elapsed time?
Notes:
The image shows Control center information for a track with a duration of 1:52:33 and current play position is 1:00:05.
The seek bar works correctly.
That looks like a macOS bug since media played using QuickTime Player also exhibits the same erroneous behavior. Please file a macOS feedback report!
I have a simple AVPlayer-based OS X app that plays local media. It has a skip forward and backward feature, based on -seekToTime:. On some media, there is an annoying 3-7 second delay in getting the media to continue playing (especially going forward). I have tried - seekToTime:toleranceBefore:toleranceAfter: , with variable tolerances. No luck.
Posting previously solved issue for the record... I noticed that the seekToTime: skipping worked fine when the playback was paused. I immediately (i.e., several weeks later) realized that it might make sense to stop the playback before seeking, then restarting. So far, problem is 100% solved, and it is blazing fast. Might be of some use to people trying to do smooth looping (but I don't know how to trigger the completion handler signaling the end of the loop). Don't know if it works with iOS. Sample code is attached:
-(void) movePlayheadToASpecificTime
{
// assumes this is a method for an AVPlayerView subclass, properly wired with IB
// self.player is a property of AVPlayerView, which points to an AVPlayer
// save the current rate
float currentPlayingRate = self.player.rate;
// may need fancier tweaking if the time scale changes within asset
int32_t timeScale = self.player.currentItem.asset.duration.timescale;
// stop playback
self.player.rate = 0;
Float64 desiredTimeInSeconds = 4.5; // or whatever
// convert desired time to CMTime
CMTime target = CMTimeMakeWithSeconds(desiredTimeInSeconds, timeScale);
// perform the move
[self.player seekToTime:target];
// restore playing rate
self.player.rate = currentPlayingRate;
}
I am making an app for myself in app inventor which calculates time. There are two buttons (start, stop) and a label to display the time.
Now my problem is that I get the resultant time which is (stop time - start time) in milliseconds but I want it in MM:SS format. I tried certain clock buttons like get instant from milliseconds and time format too, but still failed to resolve the issue.
see the screenshot how to do it
for a complete example of a countdown timer see here
I am trying to use the property of MPMoviePlayerController i.e "currentTime". But its showing warning "warning: 'MPMoviePlayerController' may not respond to '-currentTime' ". Can you please help me for how to use this property.
Actually i am trying to find out the duration of time for played video . So that i will check with timer ( NSTimer ) and than calculate how much time the played video is played or seek forward . And next time while i am playing the same video so i will start from the last spot time and play from that time when i resumed .
Thanks,
KamalBhr.
You would not see currentTime as part of MPMoviePlayerController thats a part of AVPlayer.