How play M3U8 with encrypted key in MediaPlayer

Could some one help to play m3u8 with encrypted, i can able to play m3u8 with plane key but due to some security reasons from back will be getting m3u8 with encrypted key.

Code:

public class ViewerActivity extends Activity implements Callback, OnPreparedListener, VideoControllerView.MediaPlayerControl{

public static MediaPlayer player;
public static SurfaceView surfaceView;
public static SurfaceHolder surfaceHolder;
VideoControllerView controller;
boolean isPaused = false;
@override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_videoviewer);
player = new MediaPlayer();
//controller = new VideoControllerView(this);
surfaceView = (SurfaceView)findViewById(R.id.videoSurface);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
player.setOnPreparedListener(this);

Intent intent = getIntent();
String url = intent.getStringExtra("URL");

try {
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(this, Uri.parse(url));
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@override
public void onPrepared(MediaPlayer mp)
{
// TODO Auto-generated method stub
int videoWidth = player.getVideoWidth();
int videoHeight = player.getVideoHeight();
android.view.ViewGroup.LayoutParams lp = surfaceView.getLayoutParams();
lp.width = videoWidth;
lp.height = videoHeight;
surfaceView.setLayoutParams(lp);
mp.start();

}
@override
public void surfaceCreated(SurfaceHolder holder) {
player.setDisplay(holder);
if (isPaused) {
player.start();
isPaused = false;
}
else
player.prepareAsync();

}
}

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by izaiah46
4 hours ago
Last post by ottilie.hermann
4 hours ago
lag
Started by orion79
Last post by tstracke
1 hour ago
Last post by micah.sanford
1 hour ago