 |
 |

01-31-2012, 07:59 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
|
|
Fullscreen Video Only Works Once
|
Can someone please tell me why my windows media player control is only showing the video full screen the first time it plays? After the first play, the video no longer displays as full screen.
Your help is much appreciated. Thanks!
Here is my code:
Code:
Private Sub Form_Load()
PlayNext
End Sub
Public Sub PlayNext()
Static x As Integer
'video files to play
If x = 0 Then
ShowVideo (first_video)
x = x + 1
ElseIf x = 1 Then
ShowVideo (second_video)
x = 0
End If
End Sub
Private Sub ShowVideo(Path As String)
'play video
With wmpVideo
.URL = Path
.Controls.play
.uiMode = "none"
.windowlessVideo = True
.stretchToFit = True
Do
DoEvents
Loop Until .playState = wmppsPlaying
'show full screen
.fullScreen = True
.Visible = False
End With
End Sub
Private Sub wmpVideo_PlayStateChange(ByVal NewState As Long)
'play next video when finished
If wmpVideo.playState = wmppsMediaEnded Then
wmpVideo.Controls.stop
ElseIf wmpVideo.playState = wmppsStopped Then
PlayNext
End If
End Sub
|
|

01-31-2012, 08:04 AM
|
 |
Lost Soul
Super Moderator * Guru *
|
|
Join Date: May 2001
Location: Vorlon
Posts: 18,885
|
|
|
You call the PlayNext in the Form_Load.
At this moment the Form is not shown on the screen yet.
In the ShowVideo routine you set the screen to fullscreen after the video has stopped playing.
First sort these things out and then check if it works as expected.
|
|

01-31-2012, 08:17 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
|
|
Quote:
Originally Posted by Flyguy
You call the PlayNext in the Form_Load.
At this moment the Form is not shown on the screen yet.
In the ShowVideo routine you set the screen to fullscreen after the video has stopped playing.
First sort these things out and then check if it works as expected.
|
Thank you for the response.
I moved the PlayNext sub to Form_Activate() but that still doesn't help anything. I even tried calling it with a timer but to no avail. Like I said, The video plays fullscreen on the first play as expected. It's the subsequent videos that don't display right. I do see a "flash" on the screen though like it trying to display fullscreen (<- this is the edit to the post)
Also, I tried moving the .fullscreen call before the video is playing but it gives me an error. However, in the code above the fullscreen mode is called after the video starts playing, not when it is stopped.
Any other ideas?
|
Last edited by Code A; 01-31-2012 at 08:44 AM.
Reason: Added more info
|

01-31-2012, 08:48 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,278
|
|
Set fullscreen on the playstatechanged event when it's playing...
Code:
Private Sub wmpVideo_PlayStateChange(ByVal NewState As Long)
'play next video when finished
Select Case NewState
Case wmppsMediaEnded
wmpVideo.Controls.stop
Case wmppsStopped
PlayNext
Case wmppsPlaying
If not wmpView.FullScreen then
wmpView.FullScreen = True
End if
End Select
End Sub
I ramble on about it in this thread -> http://www.xtremevbtalk.com/showthre...38#post1320138
|
__________________
There are no computers in heaven!
|

01-31-2012, 09:05 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
|
|
Quote:
Originally Posted by DrPunk
Set fullscreen on the playstatechanged event when it's playing...]
|
Dr Punk, thank you for the response. I implemented your code but it still does not seem to be working. I can see the video flash fullscreen for a split second but then it is gone and back to playing on the form at the design size of the control.
Any other ideas? Anything else I need to change?
Here is the modified code:
Code:
Private Sub Form_Activate()
PlayNext
End Sub
Public Sub PlayNext()
Static x As Integer
If x = 0 Then
ShowVideo (first_video)
x = x + 1
ElseIf x = 1 Then
ShowVideo (second_video)
x = 0
End If
End Sub
Private Sub ShowVideo(Path As String)
With wmpVideo
.URL = Path
.Controls.play
.uiMode = "none"
.windowlessVideo = True
.stretchToFit = True
Do
DoEvents
Loop Until .playState = wmppsPlaying
'.fullScreen = True
.Visible = False
End With
End Sub
Private Sub wmpVideo_PlayStateChange(ByVal NewState As Long)
'ShowStatus NewState
'play next video when finished
Select Case NewState
Case wmppsMediaEnded
wmpVideo.Controls.stop
Case wmppsStopped
PlayNext
Case wmppsPlaying
If Not wmpVideo.fullScreen Then
wmpVideo.fullScreen = True
End If
End Select
End Sub
|
|

01-31-2012, 09:09 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,278
|
|
|
I always had the media player on a form that filled the screen, i.e. the form was fullscreen too.
|
__________________
There are no computers in heaven!
|

01-31-2012, 09:11 AM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,278
|
|
|
Maybe you changing the uimode and other stuff is having an effect. You should only have to set them once when the form loads. Also try setting autostart to false.
|
__________________
There are no computers in heaven!
|

01-31-2012, 09:16 AM
|
 |
Junior Contributor
|
|
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
|
|
Quote:
Originally Posted by DrPunk
I always had the media player on a form that filled the screen, i.e. the form was fullscreen too.
|
I set the windowstate of the form to vbMaximized but that still doesn't seem to do the trick either.
This code below works. What are your thoughts on this workaround? Any concerns?
Code:
Private Sub wmpVideo_PlayStateChange(ByVal NewState As Long)
'play next video when finished
Select Case NewState
Case wmppsMediaEnded
wmpVideo.Controls.stop
Case wmppsStopped
PlayNext
Case wmppsPlaying
If Not wmpVideo.fullScreen Then
'wmpVideo.fullScreen = True
wmpVideo.Top = Me.Top
wmpVideo.Left = Me.Left
wmpVideo.Width = Me.ScaleWidth
wmpVideo.Height = Me.ScaleHeight
End If
End Select
End Sub
|
|

01-31-2012, 12:41 PM
|
 |
Multi-Technologist
Super Moderator * Expert *
|
|
Join Date: May 2004
Location: Michigan
Posts: 3,740
|
|
PlayNext within the PlayStateChange event cause a re-entrant condition (first PSC event never reaches End Sub), which seems to confuse the control. Do it this way instead, using a 1ms disabled Timer control as a trigger:
Code:
Private Sub wmpVideo_PlayStateChange(ByVal NewState As Long)
'play next video when finished
Debug.Print NewState
If wmpVideo.playState = wmppsMediaEnded Then
wmpVideo.Controls.stop
ElseIf wmpVideo.playState = wmppsStopped Then
Timer1.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
PlayNext
End Sub
Works fine for me.
|
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb
|

01-31-2012, 02:24 PM
|
 |
Junior Contributor
|
|
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
|
|
|
Thank you for the response. Your method seems to be a solution to the problem. However, I am curious if my workaround of resizing the control is essentially the same thing as "fullscreen" or not. Is there an advantage to using fullscreen instead?
|
|

02-02-2012, 07:14 AM
|
 |
Multi-Technologist
Super Moderator * Expert *
|
|
Join Date: May 2004
Location: Michigan
Posts: 3,740
|
|
|
I merged your code from post #8 into #5, so maybe I got out of sync with what you are actually doing? I was unable to get your method to work on the second video without maximizing the form (so Me.Top is near the physical top of the screen) and even then the right-click context menu for the second video was unavailable until I reverted to using my method.
If your method were to be of some value, I might try:
wmpVideo.Move Me.Left, Me.Top, Me.Width, Me.Height
or to make it independent of the form:
wmpVideo.Move 0, 0, Screen.Width, Screen.Height
but, like I said, none of this seems to work correctly on the second video (missing right-click context menu).
|
__________________
"May the code that you write never work in ways that you didn't expect; and may the code that you didn't write never require you to maintain it". - Ancient Chinese Proverb
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|