Created
February 13, 2016 20:20
-
-
Save codenameone/fb73f5d47443052f8956 to your computer and use it in GitHub Desktop.
Demo of the MediaPlayer class from Codename One
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final Form hi = new Form("MediaPlayer", new BorderLayout()); | |
| hi.setToolbar(new Toolbar()); | |
| Style s = UIManager.getInstance().getComponentStyle("Title"); | |
| FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_VIDEO_LIBRARY, s); | |
| hi.getToolbar().addCommandToRightBar(new Command("", icon) { | |
| @Override | |
| public void actionPerformed(ActionEvent evt) { | |
| Display.getInstance().openGallery((e) -> { | |
| if(e != null && e.getSource() != null) { | |
| String file = (String)e.getSource(); | |
| try { | |
| Media video = MediaManager.createMedia(file, true); | |
| hi.removeAll(); | |
| hi.add(BorderLayout.CENTER, new MediaPlayer(video)); | |
| hi.revalidate(); | |
| } catch(IOException err) { | |
| Log.e(err); | |
| } | |
| } | |
| }, Display.GALLERY_VIDEO); | |
| } | |
| }); | |
| hi.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How about an example of playing a video from a remote url?