[Cf. Skills] embedding Media Player (C #) in. Net cf #)

Source: Internet
Author: User

Someone asked yesterday at http://winbile.net/bbshow to use mediaplayer.pdf music in wm5.
In fact, Microsoft has mentioned in a multimedia case. For details, refer:
Http://www.microsoft.com/china/MSDN/library/Mobility/pocketpc/WorkingwithMultimedia.mspx
The method is a little complicated, but fortunately you can download its sample and reference it in your Managed Project.
After all, there is no way to directly operate WMP in. NET Compact framework. However, even so, we can still use managedCodeControl Windows Media Player. The basic idea is to first create a separate process for media player, and then control media player by forgetting to send messages in the form of media player. Next let's take a look at how this is done through the managed code,
First, create a process and input the following parameters:

Wmpprocess =   New Process ();
Wmpprocess. startinfo. filename =   " Wmplayer.exe " ;
Wmpprocess. startinfo. Arguments = Wmpargs;

The arguments format should be as follows: "" \ My Documents \ testvideo. WMV ""/fullscreen "; the file path must be separated from the following parameters. in C # and VB, this method of adding double quotation marks is legal.
Then, start the process and start playing the music. (If you want the user's focus to remain on your form, you should place your form on the top ), more WMP support is provided in systems above wm5.0. You can access the name of the currently played track, artist name, album name, bit rate, the playback time (accurate to milliseconds) or even the music style. Below are some examples: Artist = Systemstate. mediaplayertrackartist;
Playingtrack = Systemstate. mediaplayertracktitle;
Album = Systemstate. mediaplayeralbumtitle;
Bitrate = Systemstate. mediaplayertrackbitrate;
Style = Systemstate. mediaplayertrackgenre;

Another question is how to stop mediaplayer? We can still indirectly control it by sending messages to the form, but here we need to use a local function sendmessage. The Code is as follows:


// Reference sendmessage and name it closewmp
Private   Const Uint32 wm_close =   16 ;
[Dllimport ( " Coredll. dll " , Entrypoint =   " Sendmessage " )]
Public   Static   Extern Int32 closewmp (intptr hwnd, uint32 MSG, int32 wparam, int32 lparam );
// This is the case when it is used.
Public   Void Stopwmp ()
{
Myref. closewmp (wmpprocess. main1_whandle, wm_close,0,0);
}

ProgramThe running effect is as follows:

Click here to download the complete code.

All rights reserved by freesc Huang
Http://fox23.cnblogs.com
Hjd. Click [at] gmail.com
2008-2-18

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.