Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
App. WinForms / WPF .NET
Errore visualizzazione file avi su picturbox
lunedì 24 settembre 2007 - 17.55
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
rimmer
Profilo
| Newbie
19
messaggi | Data Invio:
lun 24 set 2007 - 17:55
Salve a tutti ,
dovrei riuscire a visualizzare un file avi o mpeg su un picturebox,il codice usato è il seguente :
Public Class Form1
Declare Function mciSendString Lib "winmm.dll" _
(ByVal IpstrCommand As String, ByVal IPstrReturnString As String, ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer
Declare Function GetShortPathName Lib "kernel32.dll" _
(ByVal lpszLongPath As String, ByVal lpszShortPath As System.Text.StringBuilder, ByVal cchBuffer As Integer) As Integer
Sub PlayAVIPictureBox(ByVal fileName As String, ByVal window As PictureBox)
Const WS_CHILD = &H40000000
Dim commandString As String
Dim shortFileName As New System.Text.StringBuilder(260)
' ricava il nome del file nel formato DOS 8+3 caratteri
GetShortPathName(fileName, shortFileName, shortFileName.Capacity)
fileName = shortFileName.ToString()
' apre la periferica
commandString = "open " & fileName & " type AVIVideo alias AVIFile parent " & window.Handle.ToString() & " style " & CStr(WS_CHILD)
ExecuteMCICommand(commandString, False)
' adatta il filmato alla PictureBox
commandString = "put AVIFile window at 0 0 " & window.Width.ToString() & " " & window.Height.ToString()
ExecuteMCICommand(commandString, True)
' riproduce il filmato
commandString = "Play AVIFile wait"
ExecuteMCICommand(commandString, True)
' chiude la periferica
commandString = "Close AVIFile"
ExecuteMCICommand(commandString, True)
End Sub
Sub ExecuteMCICommand(ByVal commandString As String, ByVal deviceAlreadyOpened As Boolean)
' si è verificato un errore
If mciSendString(commandString, vbNullString, 0, 0) <> 0 Then
' chiude la periferica se necessario
If deviceAlreadyOpened Then
commandString = "close AVIFile"
mciSendString(commandString, vbNullString, 0, 0)
End If
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PlayAVIPictureBox(Me.TextBox1.Text, Me.pic)
End Sub
End Class
Però mi dà il seguente errore come posso risolvere??
System.EntryPointNotFoundException non è stata gestita
Message="Impossibile trovare un punto di ingresso con nome 'GetShortPathName' nella DLL 'kernel32.dll'."
Source="PlayerAVI"
TypeName=""
StackTrace:
in Player.Form1.GetShortPathName(String& lpszLongPath, StringBuilder lpszShortPath, Int32 cchBuffer)
in Player.Form1.PlayAVIPictureBox(String fileName, PictureBox window) in C:\Documents and Settings\RSC\Desktop\Progetto 22 settembre\PlayerAVI\PlayerAVI\Form1.vb:riga 34
in Player.Form1.Button1_Click(Object sender, EventArgs e) in C:\Documents and Settings\RSC\Desktop\Progetto 22 settembre\PlayerAVI\PlayerAVI\Form1.vb:riga 102
in System.Windows.Forms.Control.OnClick(EventArgs e)
in System.Windows.Forms.Button.OnClick(EventArgs e)
in System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
in System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
in System.Windows.Forms.Control.WndProc(Message& m)
in System.Windows.Forms.ButtonBase.WndProc(Message& m)
in System.Windows.Forms.Button.WndProc(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
in System.Windows.Forms.Application.Run(ApplicationContext context)
in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
in Player.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:riga 81
in System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
in System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
in System.Threading.ThreadHelper.ThreadStart()
Vi ringrazio in anticipo.
Brainkiller
Profilo
| Guru
7.999
messaggi | Data Invio:
mer 26 set 2007 - 11:06
>System.EntryPointNotFoundException non è stata gestita
>Message="Impossibile trovare un punto di ingresso con nome 'GetShortPathName'
Evidentemente nella DLL non è presente questa funzione.
>Salve a tutti ,
>dovrei riuscire a visualizzare un file avi o mpeg su un picturebox,il
>codice usato è il seguente
Per me ti complichi la vita per niente io farei così, farei aprire il file direttamente con il lettore predefinito (Media Player, Winamp, ecc.).
Se proprio non sei contento e vuoi aprirlo dentro la tua applicazione, puoi referenziare nella ToolBox l'ActiveX di Media Player e caricare il video.
Ciao
David De Giacomi | Microsoft MVP
http://blogs.dotnethell.it/david/
Xnetus
Profilo
| Junior Member
130
messaggi | Data Invio:
mer 26 set 2007 - 11:18
Dai un occhiata qui:
http://www.codeproject.com/useritems/UltimatePlayer.asp
http://blogs.dotnethell.it/Xnetus/
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !