Mobile Development (continuous audio playback)

Source: Internet
Author: User

Today, I introduced a mobile audio playing technique, but I feel that I have only implemented the function and the method is not very bright. This is where you can take a look.

Search for the audioArticleMany of them rewrite the player by themselves, so I will not participate in it, and there are already many online players. If you want to use the player that comes with mobile, you can try again. In mobile, the system can automatically identify specific files by using process, suchProgram. Cab file or the. Tsk file of the topic. Is the same for audio files? The answer is yes. However, this does not meet the needs of continuous playback. We need a more general method.

The following file is a. asxfile, which is recorded after I convert it into a. txt file:

< ASX version = " 3.0 "   >
< Param name = " Encoding " Value = " UTF-8 "   />
< Entry > < REF HREF = " \ Projectf \ music \ export route along the sea " /> </ Entry >
< Entry > < REF HREF = " \ Projectf \ music \ story Contest " /> </ Entry >
</ ASX >

You may understand that when the mobile player continuously plays audio files, it will also generate such a file. If we create a specific file for the player in the program, then the player will play the video based on the file we have prepared.

Code
Private   Void Showmediaplayer ( String Musictype, infoclass info)
{
String Apppath = Path. getdirectoryname (system. reflection. Assembly. getexecutingassembly (). getname (). codebase );
Apppath = Path. Combine (apppath, @" Configxml \ MML. ASX " );

Getxmlinfo getinfo =   New Getxmlinfo ();
List < Infoclass > Infolist =   New List < Infoclass > ();
If (Musictype =   " Play " )
{
Infolist. Add (Info );
}
Else
{
Infolist=Getinfo. getdownloadlist ("Music");
}
Streamwriter SW =   New Streamwriter (apppath, False , Encoding. utf8 );
Sw. writeline ( " <ASX version = \ " 3.0 \ " > " );
Sw. writeline ( " <Param name = \ " Encoding \ " Value = \ " UTF - 8 \ " /> " );
Foreach (Infoclass infoc In Infolist)
{
Sw. writeline ("<Entry> <ref href = \""+ Infoc. Downloaded +"\"/> </Entry>");
}
Sw. writeline ( " </ASX> " );
Sw. Close ();

Process pro =   New Process ();
Pro. startinfo. filename = Apppath;
Pro. Start ();
}

When you write an audio file to. ASX, you can play one video. When multiple audio files are written, the video is automatically played continuously. However, there are still some problems. Maybe it is the problem of text display in the simulator. When displaying the song name, it is garbled. If you are interested, try it yourself.

 

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.