经过多次尝试和各种测试后,我成功地使其成为了vitamio。但现在我有一个问题。无法进行ProgressBar。 请帮忙。我一直在收到错误,android studio。
public class KanalD extends AppCompatActivity {
private static final String TAG = "MainActivity";
private String path;
//private HashMap<String, String> options;
private VideoView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.activity_player);
mVideoView = (VideoView) findViewById(R.id.vitamio_videoView);
path = "http://80.86.107.169:8100/stream.flv";
/*options = new HashMap<>();
options.put("rtmp_playpath", "");
options.put("rtmp_swfurl", "");
options.put("rtmp_live", "1");
options.put("rtmp_pageurl", "");*/
mVideoView.setVideoPath(path);
//mVideoView.setVideoURI(Uri.parse(path), options);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.setPlaybackSpeed(1.0f);
myProgressBar = (myProgressBar) findViewById(R.id.progressBar1);
myProgressBar.setVisibility(View.Gone);
}
});
}
}
而且,XML部分:
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"/>
答案 0 :(得分:0)
显然,myProgressBar
替换
myProgressBar = (myProgressBar) findViewById(R.id.progressBar1);
带
final ProgressBar myProgressBar = (ProgressBar) findViewById(R.id.progressBar1);
但是,如果myProgressBar.setVisibility(View.Gone);
被正确宣布,我就不会发现myProgressBar
可能出现的问题。