01-07-13, 02:06 PM
كيف اشغل ملف mp3 من resources بدون أن استخرج ملف mp3 من الـresources ؟
كيف اشغل ملف mp3 من resources بدون أن استخرج ملف mp3
|
01-07-13, 02:06 PM
كيف اشغل ملف mp3 من resources بدون أن استخرج ملف mp3 من الـresources ؟
05-07-13, 11:25 PM
وجدت :
Approach #1. If you really need a way to stream a video from the resource, you need to create a resource stream using the resource you need. This will give you an idea: http://social.msdn.microsoft.com/Forums/...5c93c8cfc2[^], http://msdn.microsoft.com/en-us/library/...eader.aspx[^]. Feeding the stream read from resource as the input of your Media Player control is difficult. The only input is URI. I could not find that a special Microsoft URL schema "res://" supported. As a general approach, you need to develop a special URI instead. You will need to use the constructor for the System.Uri: Uri(SerializationInfo, StreamingContext). For more information, see http://msdn.microsoft.com/en-us/library/system.uri.aspx[^]. This approach will take some effort. هل يمكن استفيد من هذا؟ فأنا لم أفهم منه
05-07-13, 11:36 PM
وهل يمكن أن استفيد من هذا أيضاً:
Playing from a resource Instead of creating a temporary file for playing a sound from a resource its both faster and doesn't create any unnecessary temp files if you create a byte array and fill it with the sounds byte, then allocate a pointer to that byte array and pass it to the sndPlaySound method with the SND_MEMORY flag. This is some code i hacked up to play from a memory stream. this is assuming there is a byte array called Sbuffer and a bool called _buffer that tells the play method if the sound file is buffered. [DllImport("winmm.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] static extern bool PlaySound(string pszSound, IntPtr hMod, SoundFlags sf); [DllImport("winmm.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)] static extern bool sndPlaySound(IntPtr ptr, int fuSound); [Flags] public enum SoundFlags : int { SND_SYNC = 0x0000, /* play synchronously (default) */ SND_ASYNC = 0x0001, /* play asynchronously */ SND_NODEFAULT = 0x0002, /* silence (!default) if sound not found */ SND_MEMORY = 0x0004, /* pszSound points to a memory file */ SND_LOOP = 0x0008, /* loop the sound until next sndPlaySound */ SND_NOSTOP = 0x0010, /* don't stop any currently playing sound */ SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */ SND_ALIAS = 0x00010000, /* name is a registry alias */ SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */ SND_FILENAME = 0x00020000, /* name is file name */ SND_RESOURCE = 0x00040004 /* name is resource name or atom */ } public void Play() { if (_buffer) { GCHandle h = GCHandle.Alloc(Sbuffer); IntPtr SoundPoint = Marshal.UnsafeAddrOfPinnedArrayElement(Sbuffer, 0); sndPlaySound(SoundPoint, (int)SoundFlags.SND_MEMORY | (int)SoundFlags.SND_ASYNC); h.Free(); } else { PlaySound(path, new System.IntPtr(), SoundFlags.SND_SYNC); } } وهو بلغة C# وليس VB.NET ولم استطع أن أفهم منه جيداً أنا قمت بتخزين الصوت في شكل Byte () هل هذا هو المقصود؟ وكيف اشغله , ملاحظة أنني خزنت الصوت في متغير باسم bb على شكل Byte () |
|