private void SetAudioFormat(ref object value)
        {
            try
            {
                object resultObject;
                string resultvalue, resulttext;

                CFControls.CFListViewItem[] audioFormatItems = new CFControls.CFListViewItem[3];
                audioFormatItems[0] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.AAC_PLUS), AudioFormats.AAC_PLUS.ToString(), 0, false, (object)AudioFormats.AAC_PLUS);
                audioFormatItems[1] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.MP3), AudioFormats.MP3.ToString(), 0, false, (object)AudioFormats.MP3);
                audioFormatItems[2] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.MP3_HIFI), AudioFormats.MP3_HIFI.ToString(), 0, false, (object)AudioFormats.MP3_HIFI);

                AudioFormats audioFormat = AudioFormats.MP3;

                try
                {
                    audioFormat = (AudioFormats)Enum.Parse(typeof(AudioFormats), this.pluginConfig.ReadField("/APPCONFIG/AUDIOFORMAT"));
                }
                catch { }

                //TODO: Pass in current value so the list shows the correct item selected initially, this doesn't seem to work as-is
                DialogResult dialogResult = this.CF_systemDisplayDialog(CF_Dialogs.FileBrowser, this.pluginLang.ReadField("/APPLANG/SETUP/AUDIOFORMAT"), null, audioFormat.ToString(), out resultvalue, out resulttext, out resultObject, audioFormatItems, false, true, false, false, false, false, 1);

                if (dialogResult == DialogResult.OK)
                {
                    audioFormat = (AudioFormats)resultObject;

                    // save user value, note this does not save to file yet, as this should only be done when user confirms settings
                    // being overwritten when they click the "Save" button.  Saving is done internally by the CFSetup instance if
                    // pluginConfig and pluginLang were properly set before callin CF_initSetup().
                    this.pluginConfig.WriteField("/APPCONFIG/AUDIOFORMAT", audioFormat.ToString());

                    // Display new value on Settings Screen button
                    ButtonValue[(int)value] = resulttext;

                    if (audioFormat == AudioFormats.MP3_HIFI)
                    {
                        CFDialogParams dialogParams = new CFDialogParams("High quality audio is only available to Pandora One subscribers. If you are not a subscriber regular quality will be used instead.");
                        this.CF_displayDialog(CF_Dialogs.OkBox, dialogParams);
                    }
                    else if (audioFormat == AudioFormats.AAC_PLUS)
                    {
                        System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly();
                        string bassAacAssemblyPath          = System.IO.Path.GetDirectoryName(assembly.Location) + "\\bass_aac.dll";

                        if (!File.Exists(bassAacAssemblyPath))
                        {
                            CFDialogParams dialogParams = new CFDialogParams("Centrafuse does not natively support the AAC audio format which is used by the mobile quality setting. To enable mobile quality playback you need to install the bass_aac.dll audio extension which can be downloaded from www.un4seen.com. Place the DLL in the Centrafuse directory. If you do not install this library you will not be able to listen to Pandora using the mobile quality setting.");
                            this.CF_displayDialog(CF_Dialogs.OkBoxBig, dialogParams);
                        }
                    }
                }
            }
            catch (Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
        }
Exemple #2
0
        private void SetBitrate(ref object value)
        {
            try
            {
                string currentBitrate = GetBitrateString();

                CFControls.CFListViewItem[] audioFormatItems = new CFControls.CFListViewItem[3];
                audioFormatItems[0] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_96k.ToString(), sp_bitrate.BITRATE_96k.ToString(), false);
                audioFormatItems[1] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_160k.ToString(), sp_bitrate.BITRATE_160k.ToString(), false);
                audioFormatItems[2] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_320k.ToString(), sp_bitrate.BITRATE_320k.ToString(), false);

                object resultObject;
                string resultvalue, resulttext;

                DialogResult result = this.CF_systemDisplayDialog(CF_Dialogs.FileBrowser, this.pluginLang.ReadField("/APPLANG/SETUP/BITRATE"), currentBitrate, currentBitrate, out resultvalue, out resulttext, out resultObject, audioFormatItems, false, true, false, false, false, false, 1);

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    this.pluginConfig.WriteField("/APPCONFIG/BITRATE", resulttext);
                    ButtonValue[(int)value] = resulttext;
                }
            }
            catch (Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
        }
        private void SetBitrate(ref object value)
        {
            try
            {
                string currentBitrate = GetBitrateString();

                CFControls.CFListViewItem[] audioFormatItems = new CFControls.CFListViewItem[3];
                audioFormatItems[0] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_96k.ToString(), sp_bitrate.BITRATE_96k.ToString(), false);
                audioFormatItems[1] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_160k.ToString(), sp_bitrate.BITRATE_160k.ToString(), false);
                audioFormatItems[2] = new CFControls.CFListViewItem(sp_bitrate.BITRATE_320k.ToString(), sp_bitrate.BITRATE_320k.ToString(), false);

                object resultObject;
                string resultvalue, resulttext;

                DialogResult result = this.CF_systemDisplayDialog(CF_Dialogs.FileBrowser, this.pluginLang.ReadField("/APPLANG/SETUP/BITRATE"), currentBitrate, currentBitrate, out resultvalue, out resulttext, out resultObject, audioFormatItems, false, true, false, false, false, false, 1);

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    this.pluginConfig.WriteField("/APPCONFIG/BITRATE", resulttext);
                    ButtonValue[(int)value] = resulttext;
                }

            }
            catch (Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
        }
        private void SetAudioFormat(ref object value)
        {
            try
            {
                object resultObject;
                string resultvalue, resulttext;

                CFControls.CFListViewItem[] audioFormatItems = new CFControls.CFListViewItem[3];
                audioFormatItems[0] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.AAC_PLUS), AudioFormats.AAC_PLUS.ToString(), 0, false, (object)AudioFormats.AAC_PLUS);
                audioFormatItems[1] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.MP3), AudioFormats.MP3.ToString(), 0, false, (object)AudioFormats.MP3);
                audioFormatItems[2] = new CFControls.CFListViewItem(GetAudioFormatDisplay(AudioFormats.MP3_HIFI), AudioFormats.MP3_HIFI.ToString(), 0, false, (object)AudioFormats.MP3_HIFI);

                AudioFormats audioFormat = AudioFormats.MP3;

                try
                {
                    audioFormat = (AudioFormats)Enum.Parse(typeof(AudioFormats), this.pluginConfig.ReadField("/APPCONFIG/AUDIOFORMAT"));
                }
                catch { }

                //TODO: Pass in current value so the list shows the correct item selected initially, this doesn't seem to work as-is
                DialogResult dialogResult = this.CF_systemDisplayDialog(CF_Dialogs.FileBrowser, this.pluginLang.ReadField("/APPLANG/SETUP/AUDIOFORMAT"), null, audioFormat.ToString(), out resultvalue, out resulttext, out resultObject, audioFormatItems, false, true, false, false, false, false, 1);

                if (dialogResult == DialogResult.OK)
                {
                    audioFormat = (AudioFormats)resultObject;

                    // save user value, note this does not save to file yet, as this should only be done when user confirms settings
                    // being overwritten when they click the "Save" button.  Saving is done internally by the CFSetup instance if
                    // pluginConfig and pluginLang were properly set before callin CF_initSetup().
                    this.pluginConfig.WriteField("/APPCONFIG/AUDIOFORMAT", audioFormat.ToString());

                    // Display new value on Settings Screen button
                    ButtonValue[(int)value] = resulttext;

                    if (audioFormat == AudioFormats.MP3_HIFI)
                    {
                        CFDialogParams dialogParams = new CFDialogParams("High quality audio is only available to Pandora One subscribers. If you are not a subscriber regular quality will be used instead.");
                        this.CF_displayDialog(CF_Dialogs.OkBox, dialogParams);
                    }
                    else if (audioFormat == AudioFormats.AAC_PLUS)
                    {
                        System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly();
                        string bassAacAssemblyPath = System.IO.Path.GetDirectoryName(assembly.Location) + "\\bass_aac.dll";

                        if (!File.Exists(bassAacAssemblyPath))
                        {
                            CFDialogParams dialogParams = new CFDialogParams("Centrafuse does not natively support the AAC audio format which is used by the mobile quality setting. To enable mobile quality playback you need to install the bass_aac.dll audio extension which can be downloaded from www.un4seen.com. Place the DLL in the Centrafuse directory. If you do not install this library you will not be able to listen to Pandora using the mobile quality setting.");
                            this.CF_displayDialog(CF_Dialogs.OkBoxBig, dialogParams);
                        }
                    }
                }
            }
            catch (Exception errmsg) { CFTools.writeError(errmsg.Message, errmsg.StackTrace); }
        }
        private void ShowSearchResults(List<SearchResult> searchResults)
        {
            WriteLog();

            if (searchResults == null || searchResults.Count == 0)
                return;

            searchResults.Sort(delegate(SearchResult searchResult1, SearchResult searchResult2)
            {
                if (searchResult1.SearchResultType == searchResult2.SearchResultType)
                    return 0;
                else if (searchResult1.SearchResultType == SearchResultTypes.Artist &&
                            searchResult2.SearchResultType == SearchResultTypes.Song)
                    return -1;
                else if (searchResult1.SearchResultType == SearchResultTypes.Song &&
                            searchResult2.SearchResultType == SearchResultTypes.Artist)
                    return 1;
                else
                    return 0; //Shouldn't happen
            });

            CFControls.CFListViewItem[] listItems = new CFControls.CFListViewItem[searchResults.Count];

            for (int i = 0; i < searchResults.Count; i++)
                listItems[i] = new CFControls.CFListViewItem(searchResults[i].ResultText, searchResults[i].MusicId, 0, false, searchResults[i] as object);

            CFDialogParams dialogParams = new CFDialogParams();
            CFDialogResults dialogResults = new CFDialogResults();
            dialogParams.displaytext = "Choose a result from the list to create a station.";
            dialogParams.listitems = listItems;

            DialogResult dialogResult = CF_displayDialog(CF_Dialogs.FileBrowser, dialogParams, dialogResults);

            if (dialogResult != DialogResult.OK)
                return;

            if (!EnsureAuthenticated("CreateStation"))
                return;

            _clientIsBusy = true;
            _pandoraClient.CreateStationAsync(dialogResults.resultvalue);
        }