示例#1
0
        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);
                }
            }
        }
示例#2
0
        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");
        }
示例#3
0
 static extern CMTimeMapping CMTimeMappingMakeEmpty(CMTimeRange target);
示例#4
0
 static extern CMTimeMapping CMTimeMappingMake(CMTimeRange source, CMTimeRange target);
示例#5
0
 public static CMTimeMapping CreateEmpty(CMTimeRange target)
 {
     return(CMTimeMappingMakeEmpty(target));
 }
示例#6
0
 public static CMTimeMapping Create(CMTimeRange source, CMTimeRange target)
 {
     return(CMTimeMappingMake(source, target));
 }
示例#7
0
 public static CMTime Fold(CMTime time, CMTimeRange foldRange)
 {
     return(CMTimeFoldIntoRange(time, foldRange));
 }
示例#8
0
 extern static CMTime CMTimeFoldIntoRange(CMTime time, CMTimeRange foldRange);
示例#9
0
        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);
        }