java - JavaFX MediaPlayer - Music stops after 10 seconds -


here's code, title says music stops after 10ish seconds, played file in vlc or other programs, lasts more 5 minutes.

public void music(){         string bip = "src/data/fjordmusic.mp3";         media hit = new media(paths.get(bip).touri().tostring());         mediaplayer mediaplayer = new mediaplayer(hit);         mediaplayer.play();     } 

your question asked , answered here: mediaplayer stop playing after 5 seconds

it seems garbage collector ereases mediaplayer instance after finishing method. put declaration of mediaplayer above method , should work.

mediaplayer mediaplayer public void music(){     string bip = "src/data/fjordmusic.mp3";     media hit = new media(paths.get(bip).touri().tostring());     mediaplayer = new mediaplayer(hit);     mediaplayer.play(); } 

(i'm not able post comments, i'm forced write answer.)


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -