asp.net Web services and flash create MP3 players

Source: Internet
Author: User
Tags new features web services root directory
Asp.net|web|web Service yesterday installed Flash MX Pro, looked at the next introduction, did add a lot of new features, add a lot of data components, and later feel asp.net development Web services so simple, so whim: I do not use C # and Flash to make a player ah. Here are some simple principles.

Write a Web service in C # that lists the. mp3 files for a given directory (mainly with some members of the System.IO) and adds it to a ArrayList, and finally publishes the ArrayList as a Web service. Then use Flash MX 2004 to create a flash document, get the Web service just published with the Webserviceconnector component, and then bind the returned results to the Flash list component, and finally, add an action to the list component. Let it double-click the mp3 file to play.

   One, Developing Web Service

The specific code is as follows, very simple, no longer said, Web services development We are very familiar with, don't say such a simple example. Here is a new mp3 folder in the root directory of the site, and then put some MP3 files inside, and finally preview the test of this Web service, the preview of the address specific to the virtual directory you established the path, I have the following.

Http://onlytiancai/bak/flashmp3/mp3services.asmx


<%@ Webservice language= "C #" class= "Mp3service"%>
Using System;
Using System.Collections;
Using System.Web.Services;
Using System.IO;

public class Mp3Service:System.Web.Services.WebService
{
Public Mp3service ()
{
}

[WebMethod]
Public ArrayList GETMP3 ()
{
ArrayList mp3list =new ArrayList ();
String mp3path = Server.MapPath ("MP3");
Try
{
DirectoryInfo di = new DirectoryInfo (Mp3path);
Fileinfo[] fi = di. GetFiles ();
foreach (FileInfo fitemp in FI)
{
if (fiTemp.Extension.ToLower () = = ". mp3" | | FiTemp.Extension.ToLower () = = ". wma")
{
Mp3list.add (Fitemp.name);
}
}
}
catch (Exception e)
{
Console.WriteLine ("The process failed: {0}", e.tostring ());
}
return mp3list;
}
}


Second, the development of Flash client

Open Flash Create a new flash document, press CTRL+SHIFT+F10 to open the Web Service panel, click the Add Web Service icon on the left, and add the first step to the Web service address that we developed, as follows.



After the success of the addition, the Web Services panel is shown below.


[1] [2] [3] Next page



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.