Dim m As MediaPlayer
m.Initialize("m",File.GetUri("D:\Kiwanis\2018-2019\Sportcommissie\DonkerRun\Rode Knop","loop.mp4"))
m.looping = true
gives error... looping is not an available property in the popup list
Dim jo As JavaObject = m
jo.RunMethod("setCycleCount",Array(noOfTimesAsAnInteger)) ' plays noOfTimesAsAnInteger times
'or
jo.RunMethod("setCycleCount",Array(jo.GetField("INDEFINITE")) ' repeats forever until stop or pause is applied
Private m as MediaPlayer
Private mv as JavaObject
m.Initialize("m",File.GetUri("D:\Kiwanis\2018-2019\Sportcommissie\DonkerRun\Rode Knop","effect5.mp4"))
mv.InitializeNewInstance("javafx.scene.media.MediaView",Array(m))
MainForm.RootPane.AddNode(mv,0,0,1000,1000)
mv.RunMethod("toBack",Null)
m.Play
Check the documentation.does the mediaplayer fire an event when the video has stopped so I can delete the node ?
m.Play
Wait For m_Complete
Check the documentation.
https://www.b4x.com/android/help/mediaplayer.html
It has an Complete event when the playing finishes.
B4X:m.Play Wait For m_Complete
Sub m_complete
Log("complete m")
Dim MediaViewNode As Node = mv
MediaViewNode.RemoveNodeFromParent
fire.Initialize("m",File.GetUri("","fire.mp4"))
firev.InitializeNewInstance("javafx.scene.media.MediaView",Array(fire))
MainForm.RootPane.AddNode(firev,0,0,1000,1000)
firev.RunMethod("toBack",Null)
fire.CycleCount = -1
fire.Play
End Sub
No.I assume that the command wait for pauses the program until m_complete is true ?
#Region Project Attributes
#MainFormWidth: 1920
#MainFormHeight: 1080
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private Aantal As Int
Private m As MediaPlayer
Private mv As JavaObject
Private fire As MediaPlayer
Private firev As JavaObject
Private Image0 As Image
Private Image1 As Image
Private Image2 As Image
Private Image3 As Image
Private Image4 As Image
Private Image5 As Image
Private Image6 As Image
Private Image7 As Image
Private Image8 As Image
Private Image9 As Image
Private EuroImage As Image
Private Nummer1 As ImageView
Private Nummer2 As ImageView
Private Nummer3 As ImageView
Private Nummer4 As ImageView
Private Nummer5 As ImageView
Private mapOfViews As Map
Private Euro As ImageView
Private money As AudioClip
End Sub
Sub AppStart (Form1 As Form, Args() As String)
Dim Getal5 As Int
MainForm = Form1
MainForm.RootPane.LoadLayout("Main")
money.Initialize(File.GetUri("","Cha_Ching_Register-Muska666-173262285.wav"))
Image0.Initialize("","0.png")
Image1.Initialize("","1.png")
Image2.Initialize("","2.png")
Image3.Initialize("","3.png")
Image4.Initialize("","4.png")
Image5.Initialize("","5.png")
Image6.Initialize("","6.png")
Image7.Initialize("","7.png")
Image8.Initialize("","8.png")
Image9.Initialize("","9.png")
EuroImage.Initialize("","euro-symbol2.png")
mapOfViews.Initialize
mapOfViews.Put("Im0", Image0)
mapOfViews.Put("Im1", Image1)
mapOfViews.Put("Im2", Image2)
mapOfViews.Put("Im3", Image3)
mapOfViews.Put("Im4", Image4)
mapOfViews.Put("Im5", Image5)
mapOfViews.Put("Im6", Image6)
mapOfViews.Put("Im7", Image7)
mapOfViews.Put("Im8", Image8)
mapOfViews.Put("Im9", Image9)
mapOfViews.Put("EuroImage",EuroImage)
Aantal = 1
Getal5 = 1
Dim GetalPNG5 As Image = mapOfViews.Get("Im"&Getal5)
Dim GetalPNG4 As Image = mapOfViews.Get("EuroImage")
Nummer4.SetImage(GetalPNG4)
Nummer5.SetImage(GetalPNG5)
fire.Initialize("m",File.GetUri("","fire.mp4"))
firev.InitializeNewInstance("javafx.scene.media.MediaView",Array(fire))
MainForm.RootPane.AddNode(firev,0,0,1000,1000)
firev.RunMethod("toBack",Null)
fire.CycleCount = -1
fire.Play
Dim jfs As JavaObject = MainForm
Dim stage As JavaObject = jfs.GetField("stage")
stage.RunMethod("setFullScreen", Array As Object(True))
MainForm.Show
End Sub
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Return True
End Sub
Sub MainForm_MouseClicked (EventData As MouseEvent)
Dim AantalStr As String
Dim lengte As Int
Dim i, x As Int
Dim getal1, getal2, getal3, getal4, getal5, groepbreedte, links As Int
Dim FadeOut As ImageView
FadeOut.Initialize("")
FadeOut.SetImage(Nummer5.GetImage)
Aantal = Aantal + 1
AantalStr = Aantal
lengte = AantalStr.Length
x = 5-lengte
For i = 1 To x
AantalStr = "0" & AantalStr
Next
getal1 = AantalStr.SubString2(0,1)
getal2 = AantalStr.SubString2(1,2)
getal3 = AantalStr.SubString2(2,3)
getal4 = AantalStr.SubString2(3,4)
getal5 = AantalStr.SubString2(4,5)
Dim GetalPNG1 As Image = mapOfViews.Get("Im"&getal1)
Dim GetalPNG2 As Image = mapOfViews.Get("Im"&getal2)
Dim GetalPNG3 As Image = mapOfViews.Get("Im"&getal3)
Dim GetalPNG4 As Image = mapOfViews.Get("Im"&getal4)
Dim GetalPNG5 As Image = mapOfViews.Get("Im"&getal5)
Select lengte
Case 1
groepbreedte = 475
links = MainForm.WindowWidth/2
links = links - (475/2)
Nummer4.Left = links
Nummer5.Left = links + 230 + 10
Euro.Visible = False
Nummer3.Visible = False
Nummer2.Visible = False
Nummer1.Visible = False
Nummer4.Visible = True
Nummer5.Visible = True
Nummer4.SetImage(EuroImage)
Nummer5.SetImage(GetalPNG5)
Case 2
groepbreedte = 230 +10 + 230 + 10 + 230
links = MainForm.WindowWidth/2
links = links - (groepbreedte/2)
Nummer3.Left = links
Nummer4.Left = links + 230 + 10
Nummer5.Left = links + 230 + 10 + 230 + 10
Euro.Visible = False
Nummer1.Visible = False
Nummer2.Visible = False
Nummer3.Visible = True
Nummer4.Visible = True
Nummer5.Visible = True
Nummer3.SetImage(EuroImage)
Nummer4.SetImage(GetalPNG4)
Nummer5.SetImage(GetalPNG5)
Case 3
groepbreedte = 230 +10 + 230 + 10 + 230 + 10 + 230
links = MainForm.WindowWidth/2
links = links - (groepbreedte/2)
Nummer2.Left = links
Nummer3.Left = links + 230 + 10
Nummer4.Left = links + 230 + 10 + 230 + 10
Nummer5.Left = links + 230 + 10 + 230 + 10 + 230 + 10
Euro.Visible = False
Nummer1.Visible = False
Nummer2.Visible = True
Nummer3.Visible = True
Nummer4.Visible = True
Nummer5.Visible = True
Nummer2.SetImage(EuroImage)
Nummer3.SetImage(GetalPNG3)
Nummer4.SetImage(GetalPNG4)
Nummer5.SetImage(GetalPNG5)
Case 4
groepbreedte = 230 +10 + 230 + 10 + 230 + 10 + 230 + 230 + 10
links = MainForm.WindowWidth/2
links = links - (groepbreedte/2)
Nummer1.Left = links
Nummer2.Left = links + 230 + 10
Nummer3.Left = links + 230 + 10 + 230 + 10
Nummer4.Left = links + 230 + 10 + 230 + 10 + 230 + 10
Nummer5.Left = links + 230 + 10 + 230 + 10 + 230 + 10 + 230 + 10
Euro.Visible = False
Nummer1.Visible = True
Nummer2.Visible = True
Nummer3.Visible = True
Nummer4.Visible = True
Nummer5.Visible = True
Nummer1.SetImage(EuroImage)
Nummer2.SetImage(GetalPNG2)
Nummer3.SetImage(GetalPNG3)
Nummer4.SetImage(GetalPNG4)
Nummer5.SetImage(GetalPNG5)
Case 5
groepbreedte = 230 +10 + 230 + 10 + 230 + 10 + 230 + 230 + 10 + 230 + 10
links = MainForm.WindowWidth/2
links = links - (groepbreedte/2)
Euro.Left = links
Nummer1.Left = links + 230 + 10
Nummer2.Left = links + 230 + 10 + 230 + 10
Nummer3.Left = links + 230 + 10 + 230 + 10 + 230 + 10
Nummer4.Left = links + 230 + 10 + 230 + 10 + 230 + 10 + 230 + 10
Nummer5.Left = links + 230 + 10 + 230 + 10 + 230 + 10 + 230 + 10 + 230 + 10
Euro.Visible = True
Nummer1.Visible = True
Nummer2.Visible = True
Nummer3.Visible = True
Nummer4.Visible = True
Nummer5.Visible = True
Euro.SetImage(EuroImage)
Nummer1.SetImage(GetalPNG1)
Nummer2.SetImage(GetalPNG2)
Nummer3.SetImage(GetalPNG3)
Nummer4.SetImage(GetalPNG4)
Nummer5.SetImage(GetalPNG5)
End Select
money.Play
Dim MediaViewNode As Node = firev
MediaViewNode.RemoveNodeFromParent
If Aantal = 10 Then
m.Initialize("m",File.GetUri("","effect6.mp4"))
mv.InitializeNewInstance("javafx.scene.media.MediaView",Array(m))
MainForm.RootPane.AddNode(mv,0,0,1000,1000)
mv.RunMethod("toBack",Null)
m.Stop
m.Play
Else
m.Initialize("m",File.GetUri("","effect5.mp4"))
mv.InitializeNewInstance("javafx.scene.media.MediaView",Array(m))
MainForm.RootPane.AddNode(mv,0,0,1000,1000)
mv.RunMethod("toBack",Null)
m.Stop
m.Play
End If
Dim l As Int = Nummer5.Left
Dim top As Int = 0 - Nummer5.Height
Dim w As Int = Nummer5.Width / 2
Dim h As Int = Nummer5.Height / 2
FadeOut.Visible = False
MainForm.RootPane.AddNode(FadeOut, Nummer5.Left, Nummer5.Top - 100, Nummer5.Width, Nummer5.Height)
Nummer5.Visible = False
FadeOut.Visible = True
FadeOut.SetLayoutAnimated(500,l-100,top,w,h)
Sleep(400)
Nummer5.Visible = True
End Sub
Sub m_complete()
Dim MediaViewNode As Node = mv
MediaViewNode.RemoveNodeFromParent
fire.Initialize("m",File.GetUri("","fire.mp4"))
firev.InitializeNewInstance("javafx.scene.media.MediaView",Array(fire))
MainForm.RootPane.AddNode(firev,0,0,1000,1000)
firev.RunMethod("toBack",Null)
fire.CycleCount = -1
fire.Play
End Sub
Use File -> Export as ZIP and upload this zip here. No one will do a new project based on your code. Additionally we are missing the layoutfile(s) you are using.I will put the code hereafter
Use File -> Export as ZIP and upload this zip here. No one will do a new project based on your code. Additionally we are missing the layoutfile(s) you are using.
The video file is missing. Note that repeating the same code or similar code is not a good practice.
fire.Initialize("m",File.GetUri("","fire.mp4"))
fire.Initialize("",File.GetUri("","fire.mp4"))
I think that you are confused from this line:
You are setting the event name to "m". The complete event is fired whenever the playback completes (it will continue automatically). When that happens 'mv' wasn't initialized yet so you get an error.B4X:fire.Initialize("m",File.GetUri("","fire.mp4"))
All that you need to do in order to play fire.mp4 forever is to remove the event sub or change the event name:
B4X:fire.Initialize("",File.GetUri("","fire.mp4"))
OK! it was that simple... ;-) thank you... that was the reason it was going into m_complete...
Now i have to figure out what to do when I click again while the second effect is playing...
When you click very fast the program hangs up...
Can I check if the fire video is running or not with
if MediaViewNode.IsInitialized = true then
endif
?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?