예제 #1
0
        static AyaRange GetMergedAyaRange(MemorizeDayInfo item1, MemorizeDayInfo item2)
        {
            AyaRange result = new AyaRange();

            result.startAyaInfo = AyaUtil.MinimumAyaRange(item1.rangeOfAyas.startAyaInfo, item2.rangeOfAyas.startAyaInfo);
            result.endAyaInfo   = AyaUtil.MaximumAyaRange(item1.rangeOfAyas.endAyaInfo, item2.rangeOfAyas.endAyaInfo);

            return(result);
        }
예제 #2
0
        static List <AyaInfo> GetRangeAyaList(AyaRange ayaRange)
        {
            var result      = new List <AyaInfo>();
            var currentSura = ayaRange.startAyaInfo.suraNumber;
            var currentAya  = ayaRange.startAyaInfo.ayaNumber;

            do
            {
                result.Add(AyaInfo.Create(currentSura, currentAya));

                if (currentAya < QuranArrayHelper.suraNumAyas[currentSura - 1])
                {
                    currentAya++;
                }
                else
                {
                    currentSura++;
                    currentAya = 1;
                }
            } while (AyaUtil.AyaTotalRank(AyaInfo.Create(currentSura, currentAya)) <= AyaUtil.AyaTotalRank(ayaRange.endAyaInfo));

            return(result);
        }
예제 #3
0
        public void GenerateJoinedMp3(int juz, DynamicGap dynamicGap, decimal fixedGap)
        {
            Processing = true;

            CleanDirectory(stageDir);
            CleanDirectory(dstDir);

            var navItems = QuranDailyPlanUtil.GetAllNavigationItems(juz);

            var blankOneSecondUrl       = blankOneSecondBaseUrl + reciter.BlankResourceName;
            var blankOneSecondLocalFile = Path.Combine(stageDir, reciter.BlankResourceName);

            using (var blankDownloadWebClient = new WebClient())
            {
                blankDownloadWebClient.DownloadFile(blankOneSecondUrl, blankOneSecondLocalFile);
            }

            int currentDay = 1;

            foreach (var navItem in navItems)
            {
                if (Processing == false)
                {
                    break;
                }

                var outFileName = Path.Combine(dstDir, string.Format("day_{0}_{1}.mp3", currentDay++, navItem.Title));
                var allFiles    = new List <AudioFile>();

                if (Processing == false)
                {
                    break;
                }

                var ayaInfos = GetRangeAyaList(navItem.rangeOfAyas);
                DownloadAyaIfNeeded(ayaInfos[0]);
                foreach (var ayaInfo in ayaInfos)
                {
                    var isLastAya   = ayaInfo.EqualsAya(ayaInfos[ayaInfos.Count - 1]);
                    var nextAyaInfo = isLastAya ? ayaInfo : AyaUtil.GetNextAyaInfoFromCurrent(ayaInfo);

                    if (isLastAya == false)
                    {
                        DownloadAyaIfNeeded(nextAyaInfo);
                    }

                    allFiles.Add(new AudioFile(FullAyaFileName(FileNameForAya(ayaInfo))));
                    var gapSeconds = GetGapForAya(ayaInfo, dynamicGap, nextAyaInfo, navItem.IsRevision) + fixedGap;
                    for (int gapNumber = 0; gapNumber < gapSeconds; gapNumber++)
                    {
                        allFiles.Add(new AudioFile(blankOneSecondLocalFile));

                        Application.DoEvents();
                    }

                    Application.DoEvents();
                }


                Combine(allFiles, outFileName);

                totalProgressBar.Value = Math.Min(100, 100 * currentDay / navItems.Count);
                Application.DoEvents();
            }

            Done();
        }