Andrew Brine
Lurker
Can anyone shed some light on the current issue I am having with playing videos within my app. The code worked before but with the upgrades to android it no longer works which is frustrating.
Here is an example of my code below:
Any help would be appreciated as I have tried everything. All it says is that is can't play video :/
Here is an example of my code below:
Code:
private String path = "https://www.domainname.tv/AppVideos/SP/Video.mp4";
private VideoView mVideoView;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ImageButton btn = (ImageButton)rootView.findViewById(R.id.playButtonStage1);
btn.setOnClickListener(this);
mVideoView = (VideoView) rootView.findViewById(R.id.videoViewStage1);
if (path.equals("")) {
// Tell the user to provide a media file URL/path.
Toast.makeText(getActivity(), "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
// return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(getActivity()));
mVideoView.requestFocus();
//mVideoView.bringToFront();
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
[USER=1021285]@override[/USER]
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mVideoView.getCurrentPosition();
}
});
}
return rootView;
// Inflate the layout for this fragment
//return inflater.inflate(R.layout.fragment_stress_management, container, false);
}
[USER=1021285]@override[/USER]
public void onClick(View v) {
mFragmentManager = getActivity().getSupportFragmentManager();
mFragmentTransaction = mFragmentManager.beginTransaction();
//mFragmentTransaction.replace(R.id.containerView, new TabFragment()).commit();
ImageButton btn = (ImageButton)v.findViewById(R.id.playButtonStage1);
Intent webLink = new Intent(Intent.ACTION_VIEW);
switch (v.getId()){
case R.id.playButtonStage1:
mVideoView.start();
btn.setVisibility(View.GONE);
break;
}
Any help would be appreciated as I have tried everything. All it says is that is can't play video :/
Last edited by a moderator: