Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Android player reload


Sometimes, if the internet is bad, the player will show error, is there any way to reload it, so I dont need to quit and enter again to reload the video?
Is there any way to auto reload if detecting error?

7 Community Answers

George

JW Player Support Agent  
0 rated :

Hi,

Is this for Android Web or Android SDK?

weijia

User  
0 rated :

Thanks for replying, its for android sdk, ideally, I wish touch the error icon to reload if it shows error.

George

JW Player Support Agent  
0 rated :

@Override
public void onError(String message) {
if(message.equals(“YOUR_ERROR_MESSAGE”)){

PlayerConfig config = mPlayerView.getConfig();
// Make any modifications you need to the config then setup
mPlayerView.setup(config);
}
}

weijia

User  
0 rated :

Thanks George, if I am using jw player in a fragment, how do I set the listener?

George

JW Player Support Agent  
0 rated :

Call getPlayer() on the Fragment then use .addOnErrorListener() to the JWPlayerView

weijia

User  
0 rated :

How do I reload my playerView?
I used the following code to initialize

PlayerConfig playerConfig = new PlayerConfig.Builder()
.file(playUrl)
.skinUrl("file:///android_assets/vapor.css")
.skinName("vapor")
.autostart(true)
.build();
mPlayerView = new JWPlayerView(getActivity(), playerConfig);
FrameLayout jwPlayerViewContainer = (FrameLayout) getActivity().findViewById(R.id.fragmentContainer);
// Add fragment to layout

jwPlayerViewContainer.addView(mPlayerView);

George

JW Player Support Agent  
0 rated :

I’m a bit confused, if you have the fragment, it already contains a player and all you should do is use getPlayer().setup(). Not sure what you’re trying to do in the code above.

This question has received the maximum number of answers.