Vous êtes sur la page 1sur 2

Public Class Form1 Private Declare Function mciSendString Lib "winmm.

dll" Alias "mciSendStringA " (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uRetur nLength As Integer, ByVal hwndCallback As Integer) As Integer Dim filename As String Dim retVal As Integer Dim File As String Dim PPState As String = "Pause" Dim TmrNum As Integer = 1000 'These are just all the stuff we will need to declare, mciSendString...etc.. . Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Even tArgs) Handles MyBase.Load retVal = mciSendString("setaudio movie volume to " & volScroll.Value, 0, 0, 0) 'Sets the volume to the trackbar filename = Chr(34) & filename & Chr(34) 'quotes around the file name retVal = mciSendString("open " & filename & " type mpegvideo alias movie ", 0, 0, 0) 'opens the file retVal = mciSendString("close movie", 0, 0, 0) 'closes the movie retVal = mciSendString("open " & filename & " type mpegvideo alias movie parent " & movieWindow.Handle.ToInt32 & " style child", 0, 0, 0) 'sets it to pl ay in the movie window... End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button1.Click Dim leftpos, Top, Width, Height As Integer 'Declareations for the size a nd pos. PPState = "Play" 'gets the state Width = movieWindow.Size.Width 'changes the width Height = movieWindow.Size.Height 'changes the height... retVal = mciSendString("resume movie", 0, 0, 0) 'i chose resume instead of play because it will play when paused... retVal = mciSendString("put movie window at " & leftpos & " " & Top & " " & Width & " " & Height, 0, 0, 0) 'alignes the movie window... Top = 0 'more aligning leftpos = 0 'more... End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button2.Click Dim newPosition As Integer = 0 'declares the position so that it will st art from the beinging retVal = mciSendString("stop movie", 0, 0, 0) 'stops it retVal = mciSendString("set movie time format ms", 0, 0, 0) 'changes for mat to milliseconds retVal = mciSendString("play movie from " & newPosition, 0, 0, 0) 'sets movie to newPosition retVal = mciSendString("stop movie", 0, 0, 0) 'Stops it.e= PPState = "Stopped" End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button3.Click retVal = mciSendString("pause movie", 0, 0, 0) 'Pauses the movie... PPState = "Pause" 'Changes the state... End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.E ventArgs) Handles Button4.Click If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then 'If t he OpenFileDialog is OK then it will do the following statements filename = OpenFileDialog1.FileName.ToString 'Sets the filename filename = Chr(34) & filename & Chr(34) 'Quotes around retVal = mciSendString("open " & filename & " type mpegvideo alias m ovie", 0, 0, 0) 'opens it... Button1.Enabled = True Button2.Enabled = True Button3.Enabled = True 'Re-enables the buttons, so you cant play nothing.. retVal = mciSendString("close movie", 0, 0, 0) 'closes it retVal = mciSendString("open " & filename & " type mpegvideo alias m ovie parent " & movieWindow.Handle.ToInt32 & " style child", 0, 0, 0) 'opens it to the movie window File = OpenFileDialog1.FileName 'Sets the file retVal = mciSendString("setaudio movie volume to " & volScroll.Value , 0, 0, 0) 'gets volume Button1_Click(Nothing, Nothing) 'hits play. End If 'I had to change it from my good un simple version ._. End Sub Private Sub volScroll_Scroll(ByVal sender As System.Object, ByVal e As Syste m.EventArgs) Handles volScroll.Scroll 'Just one line, and that line will get the volume retVal = mciSendString("setaudio movie volume to " & volScroll.Value, 0, 0, 0) End Sub End Class 'i belive that thats it...i know some of the stuff is useless, but it will help if you want to make a more advanced one...like that sneek peek of my media playe r :) 'go to my website for the beta version, which shall be up soo, http://lobsterpro ductions.weebly.com 'oops... forgot a few things... 'there we go...thanks for watching :)