Does anybody know how to switch audio channels of a video clip?
I'm currently using the "AxWindowsMediaPlayer" object to play video clips in my program, but i guess it doesn't support audio-channel controls?
Someone please help me! Thanks so much!
Printable View
Does anybody know how to switch audio channels of a video clip?
I'm currently using the "AxWindowsMediaPlayer" object to play video clips in my program, but i guess it doesn't support audio-channel controls?
Someone please help me! Thanks so much!
Anyone knows how? @"@
I just searched around on the internet...seems like there may be 3 different approaches to achieve this (I may be wrong tho):
1. Use something called "MCI"
2. Do nothing with the media player, but modify the system audio streams directly (for example, to enable right-channel audio -> discard the left channel and make a copy of the right channel to the left)
3 Use objects other than "AxWindowsMediaPlayer"
The funny thing is.. I dunno how any of these 3 approaches works!! -_-"
Maybe DirectX, but I don't have any Net examples.
hmmm...this is what i have:
VB Code:
Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As UInt32, ByVal hwndCallback As UInt32) As UInt32 Dim RefInt As Long RefInt = mciSendString("setaudio NOWMUSIC source to right", vbNull, 0, 0)
But that doesn't work. (btw it gives it gives me "ReffInt=261" when i run the mciSendString line of code)
I guess i can't use mciSendString to control a AxWindowsMediaPlayer object. Damn...
Again, I wrote this class:
VB Code:
Imports System Imports DxVBLibA Public Class Soundplayer Private Declare Function mciSendString Lib "Winmm.dll" Alias "mciSendStringA" _ (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByVal uReturnLength As System.UInt32, ByVal hwndCallback As System.UInt32) As System.UInt32 Private File As String Private m_dx As New DirectX8 Private m_ds As DirectSound8 Public Sub New(ByVal strFileName As String) Me.File = strFileName End Sub ' To show what file is selected (if needed) Public ReadOnly Property FileName() As String Get Return File End Get End Property Public Function PlaySound() As Boolean If InitAudio() = True Then If PlayFile() = True Then Return True Else Return False End If Else ' Audiohardware not found ' exit here Return False End If End Function Public Function StopSound() As Boolean StopFile() End Function Private Function PlayFile() As Boolean Dim lRet As Long Try StopFile() lRet = mciSendString("open " & Me.File & " alias track", "", 0, 0) lRet = mciSendString("play track", "", 0, 0) PlayFile = (lRet = 0) Catch ex As Exception Return False End Try Return True End Function Public Sub CloseAudio() mciSendString("close all", 0, 0, 0) End Sub Private Function StopFile() As Boolean Dim lRet As Long Try lRet = mciSendString("stop track", "", 0, 0) lRet = mciSendString("close track", "", 0, 0) Return True Catch ex As Exception Return False End Try End Function Private Function InitAudio() As Boolean m_ds = m_dx.DirectSoundCreate("") If Err.Number <> 0 Then Return False Else Return True End If End Function End Class
and have this in my Form1:
VB Code:
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then Dim Sound As New Soundplayer(OpenFileDialog1.FileName) Sound.PlaySound() End If End Sub End Class
I still get NO SOUND when opening a midi or mp3 file in Form1!!
Note:
1. When debugging, I got lRet=263 in the PlaySound() function. I know as long as IRet is not 0, the operation is unsuccessful. But what does "263" mean?
2. I added a reference to DirectX8 COM
3. I'm using Visual Studio 2005
could ANYONE plz help me?! -_-"
Use DirectX's DirectShow instead. It gives you total control over your media. I have the source code, and it was pretty easy to convert to .NET. Here's the source code:
http://www.vbforums.com/showpost.php...84&postcount=2
I don't have VS.NET in front of me, but one of the objects I believe was Quartz something. I forgot.
If u want, u can refer to this for the sample code I found on google (actually it's on codeproject.com)
http://66.102.7.104/search?q=cache:r..._zh-TW|lang_en
As you can tell..i modified the function declaration a bit coz when i use "Long" type, I get an unbalanced stack. Anyhow, I still find this error really odd...since the sample code says it's for "VB .Net". I suppose VB. Net code is a bit different from VB 2005 code?
Thx. I quickly read through your code. Seems like there's no controls for changing audio channels?Quote:
Originally Posted by Jacob Roman
I didn't add everything in that code. I'm sure there's a way somewhere. ;)
I just tried the example in the following link:
http://www.vbforums.com/showthread.p...=mcisendstring
(i.e. the third post by wldrumstcs)
Somehow my compiler can't recognize:
alsoVB Code:
Dim Id3 As New Id3() ' can't recognize the Id3() object
VB Code:
MsgBox("There was an error trying to play " & GetLastBackSlash(MP3File) & ".", MsgBoxStyle.Critical, "Error!") 'can't recognize the GetLastBackSlash() function