static CMTimeRange() { var lib = Dlfcn.dlopen(Constants.CoreMediaLibrary, 0); if (lib != IntPtr.Zero) { try { var retZero = Dlfcn.dlsym(lib, "kCMTimeRangeZero"); Zero = (CMTimeRange)Marshal.PtrToStructure(retZero, typeof(CMTimeRange)); var retInvalid = Dlfcn.dlsym(lib, "kCMTimeRangeInvalid"); #if !XAMCORE_3_0 Invalid = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange)); #endif InvalidRange = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange)); var retMappingInvalid = Dlfcn.dlsym(lib, "kCMTimeMappingInvalid"); if (retMappingInvalid != IntPtr.Zero) { InvalidMapping = (CMTimeRange)Marshal.PtrToStructure(retMappingInvalid, typeof(CMTimeRange)); } TimeMappingSourceKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingSourceKey"); TimeMappingTargetKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingTargetKey"); } finally { Dlfcn.dlclose(lib); } } }
static CMTimeRange() { var lib = Libraries.CoreMedia.Handle; var retZero = Dlfcn.dlsym(lib, "kCMTimeRangeZero"); Zero = (CMTimeRange)Marshal.PtrToStructure(retZero, typeof(CMTimeRange)); var retInvalid = Dlfcn.dlsym(lib, "kCMTimeRangeInvalid"); #if !XAMCORE_3_0 Invalid = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange)); #endif InvalidRange = (CMTimeRange)Marshal.PtrToStructure(retInvalid, typeof(CMTimeRange)); var retMappingInvalid = Dlfcn.dlsym(lib, "kCMTimeMappingInvalid"); if (retMappingInvalid != IntPtr.Zero) { InvalidMapping = (CMTimeRange)Marshal.PtrToStructure(retMappingInvalid, typeof(CMTimeRange)); } TimeMappingSourceKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingSourceKey"); TimeMappingTargetKey = Dlfcn.GetStringConstant(lib, "kCMTimeMappingTargetKey"); }
static extern CMTimeMapping CMTimeMappingMakeEmpty(CMTimeRange target);
static extern CMTimeMapping CMTimeMappingMake(CMTimeRange source, CMTimeRange target);
public static CMTimeMapping CreateEmpty(CMTimeRange target) { return(CMTimeMappingMakeEmpty(target)); }
public static CMTimeMapping Create(CMTimeRange source, CMTimeRange target) { return(CMTimeMappingMake(source, target)); }
public static CMTime Fold(CMTime time, CMTimeRange foldRange) { return(CMTimeFoldIntoRange(time, foldRange)); }
extern static CMTime CMTimeFoldIntoRange(CMTime time, CMTimeRange foldRange);
public void DidLoadTimeRange(NSUrlSession session, AVAggregateAssetDownloadTask aggregateAssetDownloadTask, CoreMedia.CMTimeRange timeRange, NSValue[] loadedTimeRanges, CoreMedia.CMTimeRange timeRangeExpectedToLoad, AVMediaSelection mediaSelection) { // This delegate callback should be used to provide download progress for your AVAssetDownloadTask. if (!activeDownloadsMap.ContainsKey(aggregateAssetDownloadTask)) { return; } var asset = activeDownloadsMap[aggregateAssetDownloadTask]; var percentComplete = 0.0; foreach (var value in loadedTimeRanges) { var loadedTimeRange = value.CMTimeRangeValue; percentComplete += loadedTimeRange.Duration.Seconds / timeRangeExpectedToLoad.Duration.Seconds; } var userInfo = new Dictionary <string, object>(); userInfo[Asset.Keys.Name] = new NSString(asset.Stream.Name); userInfo[Asset.Keys.PercentDownloaded] = new NSNumber(percentComplete); var userInfoDictionary = NSDictionary.FromObjectsAndKeys(userInfo.Values.ToArray(), userInfo.Keys.ToArray()); NSNotificationCenter.DefaultCenter.PostNotificationName(AssetPersistenceManager.AssetDownloadProgress, null, userInfoDictionary); }