i have already completed my projects by using visual basic 2008 express

but i want to know is it possible for me to add a video in splash screen..after the 10 seconds video finish, i want the want the main form to be appear..
how?

Recommended Answers

All 20 Replies

Your post will be moved to the .net forum, this is vb4/5/6

To your question, add a windows media player to your splash screen with the following code -

Try
    Me.wmp.Visible = True
    Me.wmp.FileName= "C:\SystemSecurity\SystemSecurity\HelpVedio\
    Sos_SystemSecurityDemo.avi"
            Me.wmp.Play()
            Me.wmp.Width = 1000
            Me.wmp.Height = 800
            Me.WindowState = FormWindowState.Maximized
        Catch err As Exception
            MsgBox("Invalid Input", MsgBoxStyle.Critical)
        End Try

ive already write it into the splash screen form load..but there is an error in line 5 where play is not the member of axWMPLib.WMP..

ps:how do i remove this thread to .net forum? quite new here..

I have already asked the moderators to move this post.

I will post a solution in a few minutes.:)

Have a look at the following link on how to get your media player connected correctly with the wmp library files.

axWMP Library.

sorry, i dont think that i understand the walkthrough that u provided..

dont know what is "To host the ActiveX control"

You need to create an instance of the mediaplayer BEFORE you can use it.

' Create the ActiveX control.
    Dim awmp As New AxWMPLib.AxWindowsMediaPlayer()

You must also make sure that the axWMPLibrary is referenced in your application.

Now add the code I have supplied above and let me know if this solved your problem.:)

ive added the activeX control in the module level of the form..then the error still appeard at the line 5..stated that play is not the member of wmp library

My apologies, try -

Me.wmp.Ctlcontrols.play()
'And to stop...
Me.wmp.Ctlcontrols.stop()

Sorry:)

Also have a look HERE and HERE for some more information with some nice code samples.

after i enter the code in the splash screen, this problem appeared after i press debug

"Cross-thread operation not valid: Control 'MainLayoutPanel' accessed from a thread other than the thread it was created on"

Interesting....:)

Your "MainLayoutPanel" in your application was accessed or referenced from another app etc. This is fixable though, don't worry.

Have a look at this thread HERE.It gives you a step by step on how to get to the path where the thread was created.

Alright, any word on a solution to this. I get the same 'Cross-thread operation not valid:' error. When you use the Application Framework in VB.NET and set a Splash screen, you cannot add an AxWindowsMediaPlayer control to play a video without getting the cross-thread operation error. Is it possible to play a video using a AxWindowsMediaPlayer control on another thread?

Post the code you are using and where the error occur.

It's easy to reproduce. You don't even have to write any code yourself.
Create a VB.NET Windows Forms app.
Add a Splash Screen to the project.
Add a AxWindowsMediaPlayer control to the splash screen.
Open the project properties and make sure 'Enable application framework' is checked.
Set the Splash screen: dropdown to the splash screen you added.
Run the project and you'll get an InvalidOperationException that says "Cross-thread operation not valid: Control 'SplashScreen1' accessed from a thread other than the thread it was created on."

and here is the StackTrace, which is all Framework code, so there seems to be no possible way to fix it:

at System.Windows.Forms.Control.get_Handle()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DisplaySplash()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Have you created your splash screen from scratch or did you copy it from another project? The error is not on the player, but on the splash screen.

I just added a Splash Screen project item. it could be any form. any form that you set to be the splash screen for the project will give you this error if it has a media player control on the form.

It seems that you are trying to access another thread other than the thread you are in.

Have a look at THIS thread with the exact same error and the solution.

no, i'm not trying to access anything on my own. i didn't write one line of code in this project. i did everything with the designer. the framework itself is trying to access the splash screen from another thread. this only happens when a media player control is on a form that is the splash screen. when using the Application Framework, a splash screen is loaded on a worker thread automatically.

Then I am at a loss for words. It obviously has to do with the design properties set on either the form or the player if there is absolutely no code behind it.

I'll search some more and see what I can find for you.

It has something to do with how the Application Framework is trying to get a handle to the splashscreen form to show it before the main form comes up. i can get a handle when there is not a windows media player control on the splashscreen form but an exception is thrown when there is one.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.