Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Fullscreen Video Only Works Once


Reply
 
Thread Tools Display Modes
  #1  
Old 01-31-2012, 08:59 AM
Code A's Avatar
Code A Code A is offline
Junior Contributor
 
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
Default 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
__________________
www.kptechnologies.com
Reply With Quote
  #2  
Old 01-31-2012, 09:04 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 19,057
Default

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.
Reply With Quote
  #3  
Old 01-31-2012, 09:17 AM
Code A's Avatar
Code A Code A is offline
Junior Contributor
 
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
Default

Quote:
Originally Posted by Flyguy View Post
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?
__________________
www.kptechnologies.com

Last edited by Code A; 01-31-2012 at 09:44 AM. Reason: Added more info
Reply With Quote
  #4  
Old 01-31-2012, 09:48 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

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!
Reply With Quote
  #5  
Old 01-31-2012, 10:05 AM
Code A's Avatar
Code A Code A is offline
Junior Contributor
 
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
Default

Quote:
Originally Posted by DrPunk View Post
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
__________________
www.kptechnologies.com
Reply With Quote
  #6  
Old 01-31-2012, 10:09 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

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!
Reply With Quote
  #7  
Old 01-31-2012, 10:11 AM
DrPunk's Avatar
DrPunk DrPunk is offline
Senior Contributor

* Expert *
 
Join Date: Apr 2003
Location: Never where I want to be
Posts: 1,403
Default

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!
Reply With Quote
  #8  
Old 01-31-2012, 10:16 AM
Code A's Avatar
Code A Code A is offline
Junior Contributor
 
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
Default

Quote:
Originally Posted by DrPunk View Post
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
__________________
www.kptechnologies.com
Reply With Quote
  #9  
Old 01-31-2012, 01:41 PM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,886
Default

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.
__________________
Are your apps high DPI ready?
Reply With Quote
  #10  
Old 01-31-2012, 03:24 PM
Code A's Avatar
Code A Code A is offline
Junior Contributor
 
Join Date: Jul 2002
Location: Area 51 A
Posts: 366
Default

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?
__________________
www.kptechnologies.com
Reply With Quote
  #11  
Old 02-02-2012, 08:14 AM
Cerian Knight's Avatar
Cerian Knight Cerian Knight is offline
Multi-Technologist

Super Moderator
* Expert *
 
Join Date: May 2004
Location: Michigan
Posts: 3,886
Default

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).
__________________
Are your apps high DPI ready?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->