473,396 Members | 1,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

play multifiles video in media player

How to play video one by one, if i play (press button) only the end of file is playing. If i use playlist its work, my code :

Expand|Select|Wrap|Line Numbers
  1. Dim path As String = System.AppDomain.CurrentDomain.BaseDirectory() & "Video\" 
  2.  AxWindowsMediaPlayer1.uiMode = "none"
  3.         AxWindowsMediaPlayer1.settings.setMode("loop", True)
  4.  
  5. If Not Directory.Exists(path) Then
  6.  Else
  7. Dim dInfo As DirectoryInfo = New DirectoryInfo(path)
  8. For Each File As FileInfo In dInfo.GetFiles("*.mp4")
  9.                 '' ''AxWindowsMediaPlayer1.newMedia(path & File.Name)
  10.    ''Playlist.appendItem(AxWindowsMediaPlayer1.newMedia(path & File.Name))
  11.  AxWindowsMediaPlayer1.URL = path & File.Name
  12.                 ''Application.DoEvents()
  13.  
  14.             Next
  15.             ' '' ''AxWindowsMediaPlayer1.Ctlcontrols.play()
  16.         End If
Aug 29 '14 #1
1 6901
IronRazer
83 64KB
Hi,
If you don`t use a Playlist then you will need to use the AxWindowsMediaPlayer1.PlayStateChange event to detect when the media ends so you can start the next video.

Being you can`t start the next video from within the PlayStateChange event you will need to use a Timer with a small delay like 200 milliseconds and in the Tick event you start the next video.

I take it you want a loop effect so in this example i check if it is the last video that ended and if it is then i start the first video again.

You can test the code in a new Form project with 1 Button and 1 AxWindowsMediaPlayer added to the form. You will also need a folder in the Debug folder named "Videos" with your video files in it.

Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Private WithEvents Tmr As New Timer With {.Interval = 200}
  3.     Private VideoFiles As New List(Of String)
  4.     Private VideoPath As String = IO.Path.Combine(Application.StartupPath, "Videos")
  5.     Private PlayingIndex As Integer = 0
  6.  
  7.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         For Each fn As String In IO.Directory.GetFiles(VideoPath, "*.mp4")
  9.             VideoFiles.Add(fn) 'add all the video file names to the List
  10.         Next
  11.     End Sub
  12.  
  13.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  14.         PlayingIndex = 0 'if you want it to start at the first video every timr this button is clicked
  15.         AxWindowsMediaPlayer1.URL = VideoFiles(PlayingIndex)
  16.     End Sub
  17.  
  18.     Private Sub AxWindowsMediaPlayer1_PlayStateChange(ByVal sender As Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
  19.         If AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsMediaEnded Then
  20.             Tmr.Start()
  21.         End If
  22.     End Sub
  23.  
  24.     Private Sub Tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Tmr.Tick
  25.         Tmr.Stop()
  26.         PlayingIndex += 1
  27.         If PlayingIndex > VideoFiles.Count - 1 Then PlayingIndex = 0 'if its the last video then start at the first video again
  28.         AxWindowsMediaPlayer1.URL = VideoFiles(PlayingIndex)
  29.         AxWindowsMediaPlayer1.Ctlcontrols.play()
  30.     End Sub
  31. End Class
  32.  
Aug 30 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

56
by: alan b | last post by:
I copied it and tried to edit the movie.htm below in the <PARAM NAME=*** location of the file where the videoclip is on my hard drive. It is already recorded by Windows Media Player. My version...
1
by: Michael Persaud | last post by:
Hello, I have used the sdk, with vb.net and can now play media player in my app. However i was hoping to play a memory stream into media player, is it possible? Or do i need to use another...
2
by: Dan | last post by:
I have the following code: <html> <body> <OBJECT id="VIDEO" width="320" height="240" style="position:absolute; left:0;top:0;" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"...
19
by: Tony | last post by:
I'm working on project that plays movies using Windows Media Player and I'm controlling everything with JavaScript. Per the client I only need to support IE 6 or greater which happens to make...
4
by: acknowledged74 | last post by:
Hi I have added a open and 'play in Window Media player' option on my website, do you know how I can control the size of the player that opens? It automatically open in the whole page and quality...
3
by: Phil | last post by:
Has anyone else had a problem using the AXWindowsMediaPlayer control and VB2008? It all seems to work fine for me, but I have sent my application out to a few other people to test, and I have had...
7
matheussousuke
by: matheussousuke | last post by:
I spent about 3 weeks on this. First I tried WMP embedded, didnt work (active x issue), then JW PLayer, didnt work too, then Flow Player, then Jw wmv player silver light (Yehaa, it worked,...
0
by: shameerpv | last post by:
In my page i am embedding a media player. I just want to play audio files. I only need to give support to internet explorer. The html i am using is shown below <div class="form_date" > ...
0
by: Mudassir | last post by:
There is a few different ways to show video on web page. Most popular are Windows Media Player, Quick Time, Adobe Flash or Silverlight. If you want to find out how to show video with Windows Media...
1
by: Charlie33 | last post by:
I have an href link to a php script. <a href="videodirectory/myFile.php">video file</a> The script is <?php header('Content-disposition: attachment; filename=filename.wmv');...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.