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.