Click here to Skip to main content
15,511,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to open a music file with MCI in metro style application. This code worked on wpf and windows form application, but it doesn't work on metro style application.I don't want to use media element.Please help.

Part of My code:
C#
using System.Runtime.InteropServices;
using System.Text;

[DllImport("winmm.dll")]
        private static extern long mciSendString(
            string command,
            StringBuilder returnValue,
            int returnLength,
            IntPtr winHandle);

private void OpenMediaFile(string file)
        {
            string Command = "Open \"" + file +
                                "\" type mpegvideo alias hello";
            mciSendString(Command, null, 0, IntPtr.Zero);
            mciSendString("Play hello", null, 0, IntPtr.Zero);
        }


        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            OpenMediaFile(input1.Text.ToString()); //input1 is a textbox
        }
Posted
Updated 12-Jun-12 11:37am
v2
Comments
Farhan Ghumra 15-Jun-12 7:10am    
why don't you want to use MediaElement ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900