Win8 downlevels mp3

Source: Internet
Author: User
Tags blank page

Front-end code: <Page. resources> <Style TargetType = "TextBlock"> <Setter Property = "FontSize" Value = "27"/> <Setter Property = "FontFamily" Value = ""/> </ style> </Page. resources> <Grid Background = "{StaticResource ApplicationPageBackgroundThemeBrush}"> <Grid. rowDefinitions> <RowDefinition Height = "auto"/> <RowDefinition Height = "*"/> </Grid. rowDefinitions> <StackPanel Grid. row = "0" Margin = "15, 8" Orientation = "Horizon Tal "> <TextBlock Text =" input download URI: "VerticalAlignment =" Center "/> <TextBox x: Name =" txtInputUri "Width =" 680 "/> <Button x: name = "btnDown" Margin = ", 0," VerticalAlignment = "Center" Content = "start downloading" Padding =, 17,5 "FontSize =" 22 "Click =" onDownload_Click "/> </StackPanel> <StackPanel Grid. row = "1" Margin = "20"> <ProgressBar x: name = "probar" Maximum = "100" Minimum = "0" SmallChange = "1" Width = "700" HorizontalAl Ignment = "Left" Foreground = "Yellow" Height = "30" Margin = "6, 21,"/> <TextBlock x: Name = "tbMsg" Margin = "6, 8, 0, 0 "/> </StackPanel> </Grid> </Page> background code: using System; using System. collections. generic; using System. IO; using System. linq; using Windows. foundation; using Windows. foundation. collections; using Windows. networking. backgroundTransfer; using Windows. storage; using Windows. storage. pickers; using Windows. UI. xaml; using Windows. UI. xaml. controls; using Windows. UI. xaml. controls. primitives; using Windows. UI. xaml. data; using Windows. UI. xaml. input; using Windows. UI. xaml. media; using Windows. UI. xaml. navigation; // "blank page" item template in http://go.microsoft.com/fwlink? On LinkId = 234238, the introduction namespace downLoad {/// <summary> /// can be used to itself or navigate to a blank page inside the Frame. /// </Summary> public sealed partial class MainPage: Page {public MainPage () {this. initializeComponent () ;}/// <summary> /// call when this page is to be displayed in the Frame. /// </Summary> /// <param name = "e"> describes how to access event data on this page. Parameter // properties are usually used on the configuration page. </Param> protected override void OnNavigatedTo (NavigationEventArgs e) {} private async void onDownload_Click (object sender, RoutedEventArgs e) {// determine whether the downloaded URI is input if your InputUri. text) return; // select the file storage location FileSavePicker picker = new FileSavePicker (); picker. fileTypeChoices. add ("MP3 file", new string [] {". mp3 "}); StorageFile file = await picker. pickSaveFileAsync (); if (File! = Null) {// instantiate BackgroundDownloader downloader = new BackgroundDownloader (); DownloadOperation operation = downloader. createDownload (new Uri(this.txt InputUri. text), file); // Progress SS <DownloadOperation> progressDown = new Progress <DownloadOperation> (this. progressChanged); // starts to download btnDown. isEnabled = false; var opresult = await operation. startAsync (). asTask (progressDown); bt NDown. IsEnabled = true; // determine the download result switch (opresult. Progress. Status) {case BackgroundTransferStatus. Completed: tbMsg. Text = "download Completed. "; Break; case BackgroundTransferStatus. Error: tbMsg. Text =" An Error occurred while downloading. "; Break; default: tbMsg. Text =" unknown. "; Break ;}}/// <summary >/// report progress /// </summary> private async void ProgressChanged (DownloadOperation op) {var p = op. progress; double t = p. totalBytesToReceive; // The total number of bytes to download. double d = p. bytesReceived; // number of received bytes // calculated percentage of completed bytes. double pc = d/t * 100; await Dispatcher. runAsync (Windows. UI. core. coreDispatcherPriority. normal, () => {this. probar. value = pc; this. tbMsg. text = string. format ("downloaded {0} Bytes/total {1} characters Section. ", D. ToString (" N0 "), t. ToString (" N0 "));});}}}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.