コード例 #1
0
        public override void Init(object initData)
        {
            base.Init(initData);

            if (initData is SeancesModel)
            {
                IsPresenterPage = true;
                Title           = AppResources.yoursetting;
                Model           = ((SeancesModel)initData);
            }
            else if (initData is bool)
            {
                IsPresenterPage = (bool)initData;

                if (IsPresenterPage)
                {
                    Title = AppResources.yoursetting;
                }
                else
                {
                    Title = " ";                    // AppResources.settings;

                    if (!string.IsNullOrEmpty(Settings.Language) && !string.IsNullOrEmpty(Settings.Voice))
                    {
                        DefaultLanguageEnglish = Settings.Language == "en" ? true : false;
                        DefaultGenderMan       = Settings.Voice == "male" ? true : false;
                    }
                }
            }
        }
コード例 #2
0
        public override void Init(object initData)
        {
            base.Init(initData);

            int durationInSeconds = 0;


            if (initData is SeancesModel)
            {
                SeancesModel      = ((SeancesModel)initData);
                durationInSeconds = (int)SeancesModel.Meditation.Length;

                Tint     = Color.FromHex(SeancesModel.Tint.Substring(1));
                TintDark = ((Tint).AddLuminosity(-0.2));
            }
            else
            {
                durationInSeconds = int.Parse(initData.ToString());
            }

            TotalTimeMedited = durationInSeconds;

            TotalSeconds = TimeSpan.FromSeconds(durationInSeconds);

            Progress = 0;

            step = (1 / TotalSeconds.TotalSeconds);

            Device.BeginInvokeOnMainThread(() =>
            {
                _timer = new MeditationTimer(TimeSpan.FromSeconds(1), CountDown);

                _timer.Start();
            });
        }
コード例 #3
0
        public async override void Init(object initData)
        {
            base.Init(initData);

            if (initData is SeancesModel)
            {
                IsLoading = true;

                SeanceModel = ((SeancesModel)initData);

                this.PageWasPopped += Handle_PageWasPopped;

                App.ApplicationIsPaused += App_ApplicationIsPaused;

                Tint     = Color.FromHex(SeanceModel.Tint.Substring(1));
                TintDark = ((Tint).AddLuminosity(-0.2));
                Title    = Settings.DeviceLanguage == "English" ? SeanceModel.Meditation.Label_EN : SeanceModel.Meditation.Label;

                MeditationFile meditationFile = GetMeditationFileForUser(SeanceModel.Meditation, SeanceModel.Level);

                if (meditationFile == null)
                {
                    IsLoading = false;
                    return;
                }

                AudioPlayer.PlayingChanged += AudioPlayer_PlayingChanged;
                AudioPlayer.MediaFailed    += AudioPlayer_MediaFailed;
                AudioPlayer.MediaFinished  += AudioPlayer_MediaFinished;
                AudioPlayer.StatusChanged  += AudioPlayer_StatusChanged;

                var url = Constants.RestUrl + "file/" + meditationFile.Path;

                if (SeanceModel.IsDownloaded)
                {
                    var data = await StoreManager.MeditationStore.IsAvailableOffline(SeanceModel.Meditation.Id + SeanceModel.Level + Settings.Voice + Settings.Language);

                    if (data != null && data.Item1 && data.Item2 != null)
                    {
                        var pathToFileURL = new System.Uri(data.Item2).AbsolutePath;

                        if (Device.RuntimePlatform == Device.Android)
                        {
                            Device.BeginInvokeOnMainThread(async() =>
                            {
                                await AudioPlayer.Play(file = new MediaFile(pathToFileURL, Plugin.MediaManager.Abstractions.Enums.MediaFileType.Audio, ResourceAvailability.Local));
                            });
                        }
                        else
                        {
                            Device.BeginInvokeOnMainThread(async() =>
                            {
                                await AudioPlayer.Play(file = new MediaFile("file://" + pathToFileURL));
                            });
                        }
                    }
                    else
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await AudioPlayer.Play(file = new MediaFile(url, Plugin.MediaManager.Abstractions.Enums.MediaFileType.Audio, Plugin.MediaManager.Abstractions.Enums.ResourceAvailability.Remote));
                        });
                    }
                }
                else
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await AudioPlayer.Play(file = new MediaFile(url, Plugin.MediaManager.Abstractions.Enums.MediaFileType.Audio, Plugin.MediaManager.Abstractions.Enums.ResourceAvailability.Remote));
                    });
                }
            }
        }