Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,309 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,448 people online right now. Registration is fast and FREE... Join Now!




Minimize Media Player on ESC press

 
Reply to this topicStart new topic

Minimize Media Player on ESC press

sonia.sardana
14 Oct, 2008 - 11:17 PM
Post #1

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 32

I have two buttons Play & Full Screen. If u click on Play Button,Movie starts..Movie Starts within 15-20 Seconds.....When u clik on Full Screen Button.,Media Player is Maximised. I want the if the media player is maximised,& when we click on ESC Button, Media player is minimsed.......But I m nota ble to achiev that.. Secondly I do not know that which event is used for dat KeyPress Or keyDown.. I have used both of these,But None is working/..

Mine Code is as Under.Plz go thru it..& help me it sorting out---

vb

Public Class Form1

Private Sub btnPLAY_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPLAY.Click
AxWindowsMediaPlayer1.URL = "http://www.voanews.com/wm/voa/europe/alba/alba1700vb.asx"
End Sub

Private Sub btnFULLSCREEN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFULLSCREEN.Click
AxWindowsMediaPlayer1.fullScreen = True
End Sub


Private Sub AxWindowsMediaPlayer1_KeyDownEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_KeyDownEvent) Handles AxWindowsMediaPlayer1.KeyDownEvent
If e.nKeyCode = Keys.Escape Then
If AxWindowsMediaPlayer1.fullScreen Then
AxWindowsMediaPlayer1.fullScreen = False
End If
End If
End Sub

Private Sub AxWindowsMediaPlayer1_KeyPressEvent(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_KeyPressEvent) Handles AxWindowsMediaPlayer1.KeyPressEvent
If e.nKeyAscii = 27 Then
If AxWindowsMediaPlayer1.fullScreen Then
AxWindowsMediaPlayer1.fullScreen = False
End If
End If
End Sub



End Class

User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Minimize Media Player On ESC Press
14 Oct, 2008 - 11:37 PM
Post #2

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
First you have to set your form's KeyPreview Property to true before it can recognize key events. Then use the Form's KeyDown event, like this example that will minimize the form if the escape key is pressed

vb

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
Try
Select Case e.KeyCode
Case Keys.Escape
Me.WindowState = FormWindowState.Minimized
End Select
Catch ex As Exception
MessageBox(ex.Message)
End Try
End Sub


Hope that helps smile.gif
User is offlineProfile CardPM
+Quote Post

sonia.sardana
RE: Minimize Media Player On ESC Press
15 Oct, 2008 - 12:03 AM
Post #3

New D.I.C Head
*

Joined: 1 Jun, 2008
Posts: 32

I do not want to minimise the form,I want to minimise the Media Player.....When the Movie is Running..
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:41AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month