B4J Question Play new file in MediaPlayer

bdunkleysmith

Active Member
Licensed User
Longtime User
I've not found any answer in the Forum to this, what I thought would be a common question, but apologies if I've not had a thorough look.

I have some code in a legacy project which plays a video file:

B4X:
Dim mp As MediaPlayer
Dim mv As JavaObject
Dim MediaViewNode As Node
mp.Initialize("mp",File.GetUri(p,n))           
mv.InitializeNewInstance("javafx.scene.media.MediaView",Array(mp))
MediaViewNode = mv
Display.fullPane.AddNode(MediaViewNode,0,0,-1,-1)
mp.play
MediaViewNode.Visible = True

There is other code which adjusts the location of the node (MediaViewNode) and size of the JavaObject (mv) to suit various circumstances.

Now I want to be able to load a sequence of other video files following completion of the originally loaded video file.

However I cannot see how I can just load the next file and play it. It seems I must create a new instance of the MediaPlayer and JavaObject for each new file and this is inconvenient because I have to resize the JavaObject and remove / relocate the MediaViewNode to match that previously used. It would be far better if I could use the existing instances and just point to the new file, but this may not be possible.

Any and all feedback appreciated.
 

DonManfred

Expert
Licensed User
Longtime User
Maybe load a new track?
B4X:
mp.load(path, filename) ' Load a new track
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
MediaView has a setMediaPlayer method, so you may be able to reuse the existing mediaview on a new mediaplayer. Docs are here. I can't see that they say you can't.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
Can you just re-initialize the player part, without creating a new instance? I do it with audio files, and that seems to work.
 
Upvote 0
Top