I want to make application for cricket live streaming. I want to know following things :
Currently, I have implemented web page but I am looking for other alternative.
Below is my code :
link1 = (RelativeLayout) findViewById(R.id.link1);
link2 = (RelativeLayout) findViewById(R.id.link2);
link3 = (RelativeLayout) findViewById(R.id.link3);
link4 = (RelativeLayout) findViewById(R.id.link4);
link5 = (RelativeLayout) findViewById(R.id.link5);
link6 = (RelativeLayout) findViewById(R.id.link6);
link7 = (RelativeLayout) findViewById(R.id.link7);
link1.setOnClickListener(this);
link2.setOnClickListener(this);
link3.setOnClickListener(this);
link4.setOnClickListener(this);
link5.setOnClickListener(this);
link6.setOnClickListener(this);
link7.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.link1:
linkFunction("http://changevssame.blogspot.com/2014/03/willow-cricket-hd-live-streaming.html");
break;
case R.id.link2:
linkFunction("http://changevssame.blogspot.com/2014/03/foxsports-live-streaming.html");
break;
case R.id.link3:
linkFunction("http://changevssame.blogspot.com/2014/03/sky-sports-live-streaming.html");
break;
case R.id.link4:
linkFunction("http://changevssame.blogspot.com/2014/03/ten-sports-live-streaming.html");
break;
case R.id.link5:
linkFunction("http://changevssame.blogspot.com/2014/03/star-cricket.html");
break;
case R.id.link6:
linkFunction("http://changevssame.blogspot.com/2014/03/icc-t20-world-cup-2014-live-streaming.html");
break;
case R.id.link7:
linkFunction("http://changevssame.blogspot.com/2014/03/ptv-sports.html");
break;
default:
break;
}
I will try to answer your questions but there are many fundamentals you've got to learn in order to build up a successful Streaming Application.
1. From where I can found the links to play cricket streaming ?
No idea, but this is not a SO standard question anyway.
2. Which type of links are these ?
IF you mean live streaming links, there are many types but mostly they are either HLS or RTSP. HLS links are simple HTTP links that often end with a ".m3u8" postfix. (e.g "http://somewebsite.com/streams/hls_stream_video.m3u8")
RTSP links on the other hand, have a format like this: "rtsp://somewebsite.com/streams/an_rtsp_stream.mp4"
3. Is there any player to play this type of videos ?
Absolutely. You can do so by any means. I'm not exactly sure by "a player" whether you mean Android API player or third-party player applications. So I'll cover both cases for you and future passengers.
I) Android API: You can do so with the help of a MediaController
, a MediaPlayer
and a SurafceView
. The latter two are also available in a unit entity known as VideoView
.
There is a code in the answer below, you can use that. But Be aware of two key points:
I-a) Using MediaPlayer
is harder to implement but gives you more detailed control compared to VideoView
.
I-b) If you use some code similar to the below answer Never call prepare() for network streams. Always prepareAsync(). And Always call setAudioStreamType() before prepareAsync. Otherwise you will face transient sync issues between Audio and Video when seeking on the progressbar.
II) Player Application: I have done streaming with MXPlayer and it works great.
There are some considerations to take before starting:
Assuming you are targeting Android, I can advice you to narrow your choices down to HLS and RTSP. You need to study them well before making a decision. But to give you a hint. HLS is preferred when functioning on lower Bandwidths.
There are many other topics like whether to choose UDP/TCP, IP-Multicast/Broadcast and so on...
Go and visit this tutorial. This is the most complete zero-to-hero guide in my opinion.
Since SO lacks a thorough post on Video Streaming, maybe I will extend my answer on demand.
Follow this link :
Android Video Streaming
Below code works for me :
public static void getVideoFromHttp(String urlPath) {
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(mContext);
mediacontroller.setAnchorView(mVideoview);
// Get the URL from String VideoURL
Uri mVideo = Uri.parse(urlPath);
mVideoview.setMediaController(mediacontroller);
mVideoview.setVideoURI(mVideo);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
mVideoview.requestFocus();
mVideoview.setOnPreparedListener(new OnPreparedListener() {
// Close the progress bar and play the video
public void onPrepared(MediaPlayer mp) {
mVideoview.start();
}
});
mVideoview.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With