示例#1
0
        private static string GetCurrentRegionISO()
        {
            // Get the user's geographic region and its two-letter identifier for this region.
            var geographicRegion = new Windows.Globalization.GeographicRegion();

            return(geographicRegion.CodeTwoLetter);
        }
示例#2
0
        public async Task <Artist> GetArtistInfo(string artistName)
        {
            try
            {
                var lastFmClient = new HttpClient();
                // Get users language/region
                // If their region is not support by LastFM, it won't return an artist biography.
                var    region = new Windows.Globalization.GeographicRegion();
                string url    =
                    string.Format(
                        "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={1}&api_key={0}&format=json&lang={2}",
                        App.ApiKeyLastFm, artistName, region.Code.ToLower());
                var reponse = await lastFmClient.GetStringAsync(url);

                {
                    var artistInfo = JsonConvert.DeserializeObject <ArtistInformation>(reponse);
                    if (artistInfo == null)
                    {
                        return(null);
                    }
                    if (artistInfo.Artist == null)
                    {
                        return(null);
                    }
                    var artist = new Artist();
                    artist.MapFrom(artistInfo);
                    return(artist);
                }
            }
            catch
            {
                Debug.WriteLine("Failed to get artist biography from LastFM. Returning nothing.");
            }
            return(null);
        }
示例#3
0
        public async Task <Album> GetAlbumInfo(string albumTitle, string artistName)
        {
            try
            {
                var lastFmClient = new HttpClient();
                // Get users language/region
                // If their region is not support by LastFM, it won't return an artist biography.
                var    region = new Windows.Globalization.GeographicRegion();
                string url    = string.Format(
                    "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist={1}&album={3}&api_key={0}&format=json&lang={2}",
                    MusicMDFetcher.ApiKeyLastFm, artistName, region.Code.ToLower(), albumTitle);
                var reponse = await lastFmClient.GetStringAsync(new Uri(url));

                {
                    var albumInfo = JsonConvert.DeserializeObject <AlbumInformation>(reponse);
                    if (albumInfo == null)
                    {
                        return(null);
                    }
                    if (albumInfo.Album == null)
                    {
                        return(null);
                    }
                    var album = new Album();
                    album.MapFrom(albumInfo.Album);
                    return(album);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format("Failed to get artist biography from LastFM. Returning nothing. {0}", ex));
            }
            return(null);
        }
示例#4
0
        public async Task<Artist> GetArtistInfo(string artistName)
        {
            try
            {
                var lastFmClient = new HttpClient();
                // Get users language/region
                // If their region is not support by LastFM, it won't return an artist biography.
                var region = new Windows.Globalization.GeographicRegion();
                string url =
                    string.Format(
 "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={1}&api_key={0}&format=json&lang={2}",
                        App.ApiKeyLastFm, artistName, region.Code.ToLower());
                var reponse = await lastFmClient.GetStringAsync(url);
                {
                    var artistInfo = JsonConvert.DeserializeObject<ArtistInformation>(reponse);
                    if (artistInfo == null) return null;
                    if (artistInfo.Artist == null) return null;
                    var artist = new Artist();
                    artist.MapFrom(artistInfo);
                    return artist;
                }
            }
            catch
            {
                Debug.WriteLine("Failed to get artist biography from LastFM. Returning nothing.");
            }
            return null;
        }
示例#5
0
        private string GetDeviceRegion()
        {
            // Obtain the user's home geographic region.
            var region           = GlobalizationPreferences.HomeGeographicRegion;
            var geographicRegion = new Windows.Globalization.GeographicRegion().DisplayName;

            Debug.WriteLine($"Region: { region } \nGeographic Region: { geographicRegion }");
            return(geographicRegion);
        }
        public string GetCurrentCountry()
        {
            var geographicRegion = new Windows.Globalization.GeographicRegion();
            var code             = geographicRegion?.CodeTwoLetter;

            if (!string.IsNullOrEmpty(code))
            {
                return(code);
            }
            else
            {
                return("US");
            }
        }
示例#7
0
        private void lanunchCore(IActivatedEventArgs e, bool prelaunchActivated)
        {
#if !DEBUG
            if (!AppCenter.Configured)
            {
                var region = new Windows.Globalization.GeographicRegion();
                AppCenter.SetCountryCode(region.CodeTwoLetter);
                AppCenter.Start(Telemetry.AppCenterKey, typeof(Analytics), typeof(Crashes));
            }
#endif
            if (Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Count == 0)
            {
                Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Add(new Services.ContentDialogNotification());
                Opportunity.MvvmUniverse.Services.Notification.Notificator.GetForCurrentView().Handlers.Add(new Services.InAppToastNotification());
            }
            var currentWindow  = Window.Current;
            var currentContent = currentWindow.Content;
            if (currentContent is null)
            {
                var view = ApplicationView.GetForCurrentView();
                view.SetPreferredMinSize(new Size(320, 500));
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                if (JumpList.IsSupported())
                {
                    Task.Run(async() =>
                    {
                        var jl             = await JumpList.LoadCurrentAsync();
                        jl.SystemGroupKind = JumpListSystemGroupKind.None;
                        await jl.SaveAsync();
                    });
                }
                currentContent        = new SplashControl(e.SplashScreen);
                currentWindow.Content = currentContent;
            }
            if (currentContent is SplashControl sc)
            {
                if (!prelaunchActivated)
                {
                    sc.EnableGoToContent();
                }
            }
            else
            {
                currentWindow.Activate();
            }
            ((Opportunity.UWP.Converters.Typed.StringToBooleanConverter) this.Resources["EmptyStringToFalseConverter"]).ValuesForFalse.Add("");
        }
示例#8
0
        public async Task <Artist> GetArtistInfo(string artistName)
        {
            try
            {
                var lastFmClient = new HttpClient();

                // Get users language/region
                // If their region is not support by LastFM, it won't return an artist biography.
                var    region     = new Windows.Globalization.GeographicRegion();
                string regionCode = "en";
                // LastFM does not take in normal windows region codes as valid language values.
                // We must set them ourselves.
                switch (Windows.System.UserProfile.GlobalizationPreferences.Languages.First())
                {
                case "en-US":
                    regionCode = "en";
                    break;

                case "ja":
                    regionCode = "jp";
                    break;
                }
                string url     = string.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={1}&api_key={0}&lang={2}&format=json", MusicMDFetcher.ApiKeyLastFm, artistName, regionCode);
                var    reponse = await lastFmClient.GetStringAsync(new Uri(url));

                {
                    var artistInfo = JsonConvert.DeserializeObject <ArtistInformation>(reponse);
                    if (artistInfo == null)
                    {
                        return(null);
                    }
                    if (artistInfo.Artist == null)
                    {
                        return(null);
                    }
                    var artist = new Artist();
                    artist.MapFrom(artistInfo);
                    return(artist);
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Failed to get artist biography from LastFM. Returning nothing." + exception.ToString());
            }
            return(null);
        }
示例#9
0
        public SettingService(IAmazonDataService amazonDataService, ISettingStore settingStore, ISerializer serializer)
        {
            _amazonDataService = amazonDataService;
            _settingStore      = settingStore;
            _serializer        = serializer;
            bool found;
            var  c = _settingStore.LoadAsEnum <CountryType>(CountryTypeKey, out found, roaming: true);

            if (found)
            {
                _amazonDataService.CountryType = c;
            }
            else
            {
                var locale = new Windows.Globalization.GeographicRegion().CodeTwoLetter;
                var type   = CountryType.US;
                switch (locale)
                {
                case "JP":
                    type = CountryType.Japan;
                    break;

                case "CA":
                    type = CountryType.Canada;
                    break;

                case "FR":
                    type = CountryType.France;
                    break;

                case "DE":
                    type = CountryType.Germany;
                    break;

                case "UK":
                    type = CountryType.UK;
                    break;
                }
                _amazonDataService.CountryType = type;
            }
        }
示例#10
0
        private async void lanunchCore(IActivatedEventArgs e, bool prelaunchActivated)
        {
#if !DEBUG
            if (!AppCenter.Configured)
            {
                var region = new Windows.Globalization.GeographicRegion();
                AppCenter.SetCountryCode(region.CodeTwoLetter);
                AppCenter.Start("4b9c5e4f-ebf5-46ed-9ee8-72e5de8e0236", typeof(Analytics), typeof(Crashes));
            }
#endif
            if (!Opportunity.MvvmUniverse.DispatcherHelper.Initialized)
            {
                Opportunity.MvvmUniverse.DispatcherHelper.Initialize();
                Opportunity.MvvmUniverse.DispatcherHelper.UseForNotification = true;
            }
            var currentWindow  = Window.Current;
            var currentContent = currentWindow.Content;
            if (currentContent == null)
            {
                var view = ApplicationView.GetForCurrentView();
                view.SetPreferredMinSize(new Size(320, 500));
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                currentContent        = new SplashControl(e.SplashScreen);
                currentWindow.Content = currentContent;
            }
            if (currentContent is SplashControl sc)
            {
                if (!prelaunchActivated)
                {
                    sc.EnableGoToContent();
                }
            }
            else
            {
                currentWindow.Activate();
            }
            await JYAnalyticsUniversal.JYAnalytics.StartTrackAsync("fcf0a9351ea5917ec80d8c1b58b56ff1");

            ((Opportunity.Converters.Typed.StringToBooleanConverter) this.Resources["EmptyStringToFalseConverter"]).ValuesForFalse.Add("");
        }
示例#11
0
        public async Task<Artist> GetArtistInfo(string artistName)
        {
            try
            {
                var lastFmClient = new HttpClient();

                // Get users language/region
                // If their region is not support by LastFM, it won't return an artist biography.
                var region = new Windows.Globalization.GeographicRegion();
                string regionCode = "en";
                // LastFM does not take in normal windows region codes as valid language values.
                // We must set them ourselves.
                switch (Windows.System.UserProfile.GlobalizationPreferences.Languages.First())
                {
                    case "en-US":
                        regionCode = "en";
                        break;
                    case "ja":
                        regionCode = "jp";
                        break;
                }
                string url = string.Format("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={1}&api_key={0}&lang={2}&format=json", MusicMDFetcher.ApiKeyLastFm, artistName, regionCode);
                var reponse = await lastFmClient.GetStringAsync(new Uri(url));
                {
                    var artistInfo = JsonConvert.DeserializeObject<ArtistInformation>(reponse);
                    if (artistInfo == null) return null;
                    if (artistInfo.Artist == null) return null;
                    var artist = new Artist();
                    artist.MapFrom(artistInfo);
                    return artist;
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine("Failed to get artist biography from LastFM. Returning nothing." + exception.ToString());
            }
            return null;
        }
示例#12
0
        public async Task <Music> GetMusicEntityViaArtistId(string[] artistIds, Extras[] extras)
        {
            var xboxArtistItem = new XboxMusicLibrary.Models.Artist();

            try
            {
                // TODO: Client secret should be hidden. Hence why it's "secret"
                // TODO: Remove XboxMusicAuthenication from the music view model.
                if (Locator.MusicLibraryVM.XboxMusicAuthenication == null)
                {
                    Locator.MusicLibraryVM.XboxMusicAuthenication = await Locator.MusicLibraryVM.XboxMusicHelper.GetAccessToken("5bf9b614-1651-4b49-98ee-1831ae58fb99", "copuMsVkCAFLQlP38bV3y+Azysz/crELZ5NdQU7+ddg=", string.Empty);

                    Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime = GetUnixTime(DateTime.Now);
                }
                var expiresIn = Convert.ToInt64(Locator.MusicLibraryVM.XboxMusicAuthenication.ExpiresIn);
                if (GetUnixTime(DateTime.Now) - Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime >= expiresIn)
                {
                    Locator.MusicLibraryVM.XboxMusicAuthenication = await Locator.MusicLibraryVM.XboxMusicHelper.GetAccessToken("5bf9b614-1651-4b49-98ee-1831ae58fb99", "copuMsVkCAFLQlP38bV3y+Azysz/crELZ5NdQU7+ddg=", string.Empty);

                    Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime = GetUnixTime(DateTime.Now);
                }
                Debug.WriteLine("Connecting to XBOX Music API for ");
                Debug.WriteLine("XBOX Music token " + Locator.MusicLibraryVM.XboxMusicAuthenication);
                var   region    = new Windows.Globalization.GeographicRegion();
                Music xboxMusic = await Locator.MusicLibraryVM.XboxMusicHelper.LookupMediaCatalog(Locator.MusicLibraryVM.XboxMusicAuthenication.AccessToken, artistIds, extras, new Culture(region.Code.ToLower(), null));

                Debug.WriteLine("XBOX Music artist found : " + xboxArtistItem.Name);

                return(xboxMusic);
            }
            catch (Exception e)
            {
                Debug.WriteLine("XBOX Error\n" + e);
            }
            return(null);
        }
示例#13
0
 public async Task<Album> GetAlbumInfo(string albumTitle, string artistName)
 {
     try
     {
         var lastFmClient = new HttpClient();
         // Get users language/region
         // If their region is not support by LastFM, it won't return an artist biography.
         var region = new Windows.Globalization.GeographicRegion();
         string url = string.Format(
             "http://ws.audioscrobbler.com/2.0/?method=album.getinfo&artist={1}&album={3}&api_key={0}&format=json&lang={2}",
             MusicMDFetcher.ApiKeyLastFm, artistName, region.Code.ToLower(), albumTitle);
         var reponse = await lastFmClient.GetStringAsync(new Uri(url));
         {
             var albumInfo = JsonConvert.DeserializeObject<AlbumInformation>(reponse);
             if (albumInfo == null) return null;
             if (albumInfo.Album == null) return null;
             var album = new Album();
             album.MapFrom(albumInfo.Album);
             return album;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(string.Format("Failed to get artist biography from LastFM. Returning nothing. {0}", ex));
     }
     return null;
 }
示例#14
0
        /// <summary>
        /// 최종 사용자가 응용 프로그램을 정상적으로 시작할 때 호출됩니다. 다른 진입점은
        /// 특정 파일을 여는 등 응용 프로그램을 시작할 때
        /// </summary>
        /// <param name="e">시작 요청 및 프로세스에 대한 정보입니다.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            #region for Mobile Center
            // Get the user's geographic region and its two-letter identifier for this region.
            var geographicRegion = new Windows.Globalization.GeographicRegion();
            var code             = geographicRegion.CodeTwoLetter;

            //MobileCenter.LogLevel = LogLevel.Verbose;
            MobileCenter.SetCountryCode(code);
            MobileCenter.Start("f7981365-4bfc-4008-a33e-e293fa5e575d", typeof(Analytics), typeof(Crashes));
            #endregion

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                //this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            // 창에 콘텐츠가 이미 있는 경우 앱 초기화를 반복하지 말고,
            // 창이 활성화되어 있는지 확인하십시오.
            if (rootFrame == null)
            {
                //MVVM 초기화
                GalaSoft.MvvmLight.Threading.DispatcherHelper.Initialize();
                FontHelper.FontDAO = SimpleIoc.Default.GetInstance <FontDAO>();

                // 탐색 컨텍스트로 사용할 프레임을 만들고 첫 페이지로 이동합니다.
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 이전에 일시 중지된 응용 프로그램에서 상태를 로드합니다.
                }

                // 현재 창에 프레임 넣기
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    //이전에 풀스크린으로 끝났었다면 강제로 종료시킴
                    if (IsMobile)
                    {
                        var cv = ApplicationView.GetForCurrentView();
                        if (cv.IsFullScreenMode)
                        {
                            cv.ExitFullScreenMode();
                        }
                    }
                    // 탐색 스택이 복원되지 않으면 첫 번째 페이지로 돌아가고
                    // 필요한 정보를 탐색 매개 변수로 전달하여 새 페이지를
                    // 구성합니다.
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // 현재 창이 활성 창인지 확인
                Window.Current.Activate();
            }
        }
示例#15
0
        public async Task<Music> GetMusicEntityViaArtistId(string[] artistIds, Extras[] extras)
        {
            var xboxArtistItem = new XboxMusicLibrary.Models.Artist();
            try
            {
                // TODO: Client secret should be hidden. Hence why it's "secret"
                // TODO: Remove XboxMusicAuthenication from the music view model.
                if (Locator.MusicLibraryVM.XboxMusicAuthenication == null)
                {
                    Locator.MusicLibraryVM.XboxMusicAuthenication = await Locator.MusicLibraryVM.XboxMusicHelper.GetAccessToken("5bf9b614-1651-4b49-98ee-1831ae58fb99", "copuMsVkCAFLQlP38bV3y+Azysz/crELZ5NdQU7+ddg=", string.Empty);
                    Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime = GetUnixTime(DateTime.Now);
                }
                var expiresIn = Convert.ToInt64(Locator.MusicLibraryVM.XboxMusicAuthenication.ExpiresIn);
                if (GetUnixTime(DateTime.Now) - Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime >= expiresIn)
                {
                    Locator.MusicLibraryVM.XboxMusicAuthenication = await Locator.MusicLibraryVM.XboxMusicHelper.GetAccessToken("5bf9b614-1651-4b49-98ee-1831ae58fb99", "copuMsVkCAFLQlP38bV3y+Azysz/crELZ5NdQU7+ddg=", string.Empty);
                    Locator.MusicLibraryVM.XboxMusicAuthenication.StartTime = GetUnixTime(DateTime.Now);
                }
                Debug.WriteLine("Connecting to XBOX Music API for ");
                Debug.WriteLine("XBOX Music token " + Locator.MusicLibraryVM.XboxMusicAuthenication);
                var region = new Windows.Globalization.GeographicRegion();
                Music xboxMusic = await Locator.MusicLibraryVM.XboxMusicHelper.LookupMediaCatalog(Locator.MusicLibraryVM.XboxMusicAuthenication.AccessToken, artistIds, extras, new Culture(region.Code.ToLower(), null));

                Debug.WriteLine("XBOX Music artist found : " + xboxArtistItem.Name);

                return xboxMusic;
            }
            catch (Exception e)
            {
                Debug.WriteLine("XBOX Error\n" + e);
            }
            return null;
        }