I embedded the Windows Media Player in a Microsoft Access form. I need to start playing videos from a specific time position. How can I set up the start position in VBA?
This is the code where I need to control WindowsMediaPlayer object, when clicking on a form list item the record should start playing let say... from 5th minute:
Sub SearchList_Click()
Me.WindowsMediaPlayer.URL = Me.SearchList.Column(2)
End Sub
Write:
Me.WindowsMediaPlayer.Contents.CurrentPosition=300
Ref:
https://learn.microsoft.com/en-us/windows/win32/wmp/object-model-reference-for-scripting
https://learn.microsoft.com/en-us/windows/win32/wmp/controls-object
https://learn.microsoft.com/en-us/windows/win32/wmp/controls-currentposition
Related
I am building a simple program around an Access database using VB.net, and I'm having an issue.
As shown in the screen capture provided, I have a Next Record and Previous record button to navigate the database's information on this particular tab control. The Next Record button works fine (though I would like to make it loop back to the start once Next Record is clicked on the last record), but the Previous Record button erases both name labels while still displaying the band name, country, instrument, and ID number. The code for the Previous Record button is:
Private Sub btnPrev_Click(sender As Object, e As EventArgs) Handles btnPrev.Click
Me.MusiciansBindingSource.MovePrevious()
End Sub
I have tried repopulating the data with Me.MusiciansTableAdapter.Fill(Me.MusiciansDataSet.Musicians) before the record moves back, but that didn't work. I'm at a loss for what else to try. Here is the aforementioned screen capture.
I can provide more information if needed. Thanks in advance!
Using either the Designer properties or by programming it directly, I cannot seem to get a tool tip to display the way I thought I should be able when I hover over the control.
For instance, although I can display the text I want, no matter what I set as the AutoPopDelay (I want 30 seconds) or as the background color (I want a Yellow), the tool tip always comes up for the default 5 seconds on a gray background only.
Below is the sub that I programmed. What am I missing?:
Private Sub lblUploadFileTypeHelp_MouseHover(sender As Object, e As EventArgs) Handles lblUploadFileTypeHelp.MouseHover
ToolTip1.OwnerDraw = True
ToolTip1.IsBalloon = True
ToolTip1.BackColor = Color.LemonChiffon
ToolTip1.AutoPopDelay = 30000
ToolTip1.Show("Sample text to display", lblUploadFileTypeHelp)
End Sub
IsBalloon is being taken into consideration before OwnerDraw.
You would need to handle your own drawing to get a custom display.
Have a look at the MSDN code sample MSDN Tooltip
I want the 32 radiobuttons individually be able to be linked to a database when I click the 1 button which says "Submit". Meaning when I select 1 radio button and i click the submit button I would like to have a msg saying booking confirmed or something and when i click the submit button it stores it in the database. I have tried to develop something similar to this I tried making normal textboxs being able to store it in a database. How do I link MS Access to Visual Basic in order for the radio buttons to work? Would the Primary Key be the Field called Seats if thats where I want to store the data from that field in the table?
The Form comprises of:
PictureBox - which is an image that is a layout seating plan on a plane.
32 RadioButtons
1 Radio Button = 1 seat ideally
1 Button - When the user has chosen a seat they want they should click a button called "Submit". When the button is clicked I want the seat that the user has clicked on be able to be stored into a table within a database. Once the seat has been stored the next user after the previous one isn't allowed to select that particular seat that someone else has picked. I want this to be a looping process for 32 seats on the airplane until the plane is full.
Would I use a While loop for this to work or would I use an If statement and keep on saying ElseIF in my code?
Any Ideas?
for all radio buttons set seat number as text and then assign the same event handler for CheckedChanged event of all radio buttons and write the following code within that event handler.
Private Sub RadioButton1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioButton1.CheckedChanged, RadioButton2.CheckedChanged, ...
Dim RB As RadioButton = sender
If RB.Checked Then
'write the code to save the seat number i.e. RB.Text to database
End If
End Sub
First of all I would like to thank all of you guys. Maybe you did not notice but you help me to grasp VBA to some level from scratch. I am still in learning process so I may be missing something really simple, please be gentle :)
First of all I would like to give a small backgroud update about my issue. I have been writing a small program to scan incoming parts to my work to be able to keep inventory status. Latest look of the program is like below:
And numbers on the picture are my nightmares lately:
1. Scanned Part Number: This is the textbox where scanner inputs the value. After I receive the input I immidietly convert that data to a variable and clear the textbox value as below:
Private Sub PN_CurrentScan_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
EnteredPN = Replace(PN_CurrentScan.Value, Chr(32), "", 1) '<---PN_CurrentScan is the name of text box
EnteredPN = Left(EnteredPN, 12)
PN_CurrentScan.Value = ""
After making some corrections on the scanned data I basically write it to a sheet in the workbook. Then I also have a pivot table in the same workbook which uses this scanned data as source and counts how many parts scanned from each part number.
2. Current Status: This ListBox contains all the part numbers scanned (Coming from the pivot table mentioned above) and waiting to be scanned (Coming from another worksheet). Then it refreshes it self every time a new part is scanned.
3. ListBox Scroll Bar: Since I have very long part number list it is not possible for me to fit everything on the screen that is why listbox creates this scroll bar.
Enough with the background I think :)
So if we come to my concern. Since my collages using cordless scanner to do this operation sometimes they don't have the chance to see the screen so they can not understand if the cursor is on the "Scanned Part Number Text Box" or not. That is why I need focus to be on that box no matter what happens (Of course we can not do anything if warehouse burns down, earth quake or tsunami hits the place but let do not think about those).
WHAT I HAVE TRIED:
First of all I disabled all the remaining objects from properties window
Then I diabled tab stops of all controls:
Dim contr As Control
For Each contr In ScannerInterface.Controls
On Error Resume Next
contr.TabStop = False
Next
ScannerInterface.PN_CurrentScan.TabStop = True
Added setfocus property to all button clicks:
Me.PN_CurrentScan.SetFocus
Added setfocus property to listbox click:
Private Sub CurrentStatus_List_Click()
Me.PN_CurrentScan.SetFocus
End Sub
Added set focus to enter and exit events of listbox however this did not work:
Private Sub CurrentStatus_List_Enter()
Me.PN_CurrentScan.SetFocus
End Sub
Private Sub CurrentStatus_List_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.PN_CurrentScan.SetFocus
End Sub
So, with all these counter measures I have managed to improve up to somepoint, only concern remaining is when I click on the scroll bar next to the listbox, text box lose focus and without clicking in the textbox I could not manage to set the focus again. I tried all events with listbox non of them worked. Is there any way to solve this problem or do I need to deal with this? Thanks in advance for your supports.
SOLUTION:
Thanks to #Rory we have managed to solve my problem. As he noticed and explained in the answer below, both my textbox and listbox were in frames. I have tried several setfocus options but I always gave the focus to the textbox. However, solution was to give the focus to the frame which was containing the target textbox:
Private Sub CurrentStatus_Frame_Enter() '<-- Enter event of the frame which contains listbox
Me.PN_CurrentScan.SetFocus '<-- Setfocus to target textbox
Me.Scanned_Frame.SetFocus '<-- Setfocus to frame which contains target textbox
End Sub
Having (eventually) noticed that both of your controls are inside container Frame controls, you can actually use the Enter event of the Frame that contains the listbox to set focus to the Frame that contains the textbox, rather than to the textbox itself.
I am trying to make a video player for a project which seems to be quite a challenge when I came to a stage where I need to show a time code (sort of time stamp) in a label next to the video being played.
The function of the program is...The movie file name contains the recording start time of the movie file in the format "17:56:33_Camera01.avi". When I load the movie in the player using the URL and click play the movie plays. I use a timer to get the current position of the playback in seconds,minutes and hours using the below method in the timer tick sub.
Dim PlayHour, PlayMin, PlaySec As Integer
Dim iSecond As Double = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Dim iSpan As TimeSpan = TimeSpan.FromSeconds(iSecond)
PlayHour = iSpan.Hours.ToString.PadLeft(2, "0"c)
PlayMin = iSpan.Minutes.ToString.PadLeft(2, "0"c)
PlaySec = iSpan.Seconds.ToString.PadLeft(2, "0"c)
My requirement is to dynamically set a time code in the label by adding the current position hour, minute and second to the recorded time of the movie.
For example the movie file will show the time code as 17:56:33" when loaded, when the playback begins the seconds,minutes and hours (17:56:34, 17:56:35 and so...) should start incrementing in accordance with the actual time of the playback.
Can any one please guide me in the right direction... I am breaking my head on this since quite some time and heading no where...I am quite sure I have to use Timespan for this but don't know how to get this done.
Stick this in the tick event of a timer and set the interval to 1...
Dim controls As WMPLib.IWMPControls3 = axWindowsMediaPlayer1.Ctlcontrols
controls.currentPositionTimecode = "[00000]01:00:30.05"
Label1.Text = controls.currentPositionString
All you'll need to change is "Label1" and "axWindowsMediaPlayer1". You might want to play around with "[00000]01:00:30.05" to get the format you require; this displays mm:ss.
hii add label to media and this code to timer of track bar
` TrackBar2.Maximum = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.duration
Label3.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentPositionString
TrackBar2.Value = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition
Label4.Text = AxWindowsMediaPlayer1.Ctlcontrols.currentItem.durationString `