[英]codename one mediaplayer not working on android device
i am creating a mediaplayer app which is supposed to stream mp3 files from remote url.the problem is that the everything works fine on the codename one simulator but not on an actual android device.I want the app to show native player controls like on the simulator.below is my code and screenshots 我正在创建一个Mediaplayer应用程序,该应用程序应该从远程URL流mp3文件。问题是,一切都可以在代号为一个模拟器上正常运行,但不能在实际的android设备上正常运行。我希望该应用程序显示本地播放器控件,例如Simulator.below是我的代码和屏幕截图
try {
video = MediaManager.createMedia(sample_url,true);
Display.getInstance().callSerially(() -> {
if (mp != null){
mp.getMedia().cleanup();
}
Image samp = theme.getImage("sample.png");
Label samlabel = new Label();
samlabel.setIcon(samp);
mp = new MediaPlayer(video);
mp.setAutoplay(false);
video.setNativePlayerMode(true);
sample.add(BorderLayout.CENTER,BorderLayout.centerAbsolute(samlabel));
sample.add(BorderLayout.SOUTH,mp);
//songDetails.add(mp);
});
the first image is the simulator screenshot and the second image is the actual android device screenshot 第一张图片是模拟器屏幕截图,第二张图片是实际的android设备屏幕截图
It's unclear from your post if this is an mp3
which is audio and doesn't have media control or an actual video. 从您的帖子中还不清楚这是
mp3
音频文件,没有媒体控制或实际视频。 The MediaPlayer
class is strictly for video and you passed true
to indicate that this is a video file so I'll treat it as such. MediaPlayer
类严格用于视频,并且您传递true
表示这是一个视频文件,因此我将其视为此类。
Notice that if this is an audio file then you need to add/create your own controls and shouldn't use the MediaPlayer
class. 请注意,如果这是一个音频文件,则您需要添加/创建自己的控件,并且不应使用
MediaPlayer
类。
We recently defined behaviors for native media control rendering as explained here . 最近,我们定义了本地媒体的控制渲染行为作为解释在这里 。
Just use: 只需使用:
video.setVariable(Media.VARIABLE_NATIVE_CONTRLOLS_EMBEDDED, true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.