Getting "Can't Play this Video" message in some devices only - android

I have placed a video in res folder, So the location of this video is res/splash_video.mp4. I am playing this video at the Launch of Application like this.
String uriPath= "android.resource://"+getPackageName()+"/raw/"+R.raw.splash_video;
Uri uri= Uri.parse(uriPath);
videoView.setVideoURI(uri);
videoView.start();
This video is working perfectly fine in most of the devices, but in some it displays Can't play this video message.
In Android OS 5.1 (Samsung s4), it display error message, while in Android OS 5.1 Huawei, its playing the video. Video is also working fine on Samsung s5, and samsung s7. In Note 3 it can't play this video.
Are there any different folders per devices? or do i need to place the video in some other folder, or change the format of video?
Kindly guide me how to play video on each and every device.

Use following ViewView Code:
VideoView videoHolder = new VideoView(this);
setContentView(videoHolder);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.splash);
videoHolder.setVideoURI(video);
videoHolder.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
jumpMain();
}
});
videoHolder.start();
videoHolder.setOnTouchListener(new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
((VideoView) v).stopPlayback();
jumpMain();
return true;
}
});
for full tutorial, refer:
http://www.sherif.mobi/2012/06/how-to-play-video-from-resources.html

Related

How to play Vimeo video using Vimeo networking library?

I am using Vimeo for video hosting. But I don't know how to play video in my Android app. I have got the Vimeo-networking library here 'https://github.com/vimeo/vimeo-networking-java' but unable to play video. I am confused which code exacly used for playing video. Please help me. I am new to Vimeo.
String uri = what url?;
VimeoClient.getInstance().fetchNetworkContent(uri, new ModelCallback<Video>(Video.class) {
#Override
public void success(Video video) {
//what to do now?
}
#Override
public void failure(VimeoError error) {
// voice the error
}
});

VideoView not playing in Android Application

Scenario
I have an Android App that utilizes a master/details layout.
So When I click "Videos" in the left panel, it navigates to a new panel where the video name and link is downloaded. Upon then selecting a title, the left panel hides and the video begins to play.
Problem
I've use a videoview, and oddly, I cant get the video to play. I dont really get an error, However the screen remains black, and I believe i hear the sound from the first few second of the video followed by the image i uploaded and no image.
See Code
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_drone_life3, null);
vidView=(VideoView)view.findViewById(R.id.ivEvent);
context=this.getActivity();
return view;
}
public void onItemClick(AdapterView<?> adapterView, View view,
int position, long id) {
if (new ConnectionDetector(context).isConnectingToInternet()) {
//get VidLink variable of item in this location and place in the var videoLink
videoLink = eventsDTOs.get(position).getVidLink();
try {
MediaController mediaController = new MediaController(getContext());
mediaController.setAnchorView(vidView);
Uri video = Uri.parse(videoLink);
vidView.setMediaController(mediaController);
vidView.setVideoURI(video);
vidView.start();
MainActivity.closeSlidingDrawer();
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(getContext(), "Error connecting", Toast.LENGTH_SHORT).show();
}
// new TaskGetEventImage().execute(eventsDTOs.get(position).getId());
} else {
Toast.makeText(context, context.getResources().getString(R.string.NETWORK_ERROR),Toast.LENGTH_LONG).show();
}
}
For playing video from URL
VideoView videoView=(VideoView) findViewById(R.id.myVideo);
videoView.setVideoURI(Uri.parse("http://website.com/somevideoname.mp4"));
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();
For playing video from SD card or internal storage
MediaController vidControl;
String sdPath;
VideoView videoView=(VideoView) findViewById(R.id.myVideo);
vidControl = new MediaController(this);
vidControl.setAnchorView(videoView);
videoView.setMediaController(vidControl);
videoView.setVideoPath(sdPath);
videoView.requestFocus();
videoView.start();
I will suggest to try to use above solution for playing video.
Solved this, apprantly the error was my server doing some encoding that the phone couldnt handle.

How to play a streaming video from URL in android?

I want to play a streaming video in android from a website.
For example, I want to play the streaming video from this url: http://florotv.com/canal2.html
Using URL Helper, I have been able to capture the rtmp URL that it's
rtmp://198.144.153.139:443/kuyo<playpath>ver44?id=acf6f5271f8ce567ed6c8737ce85a044&pid=32342e3136362e37332e323139 <swfUrl>http://yukons.net/yplay2.swf <pageUrl>http://yukons.net/embed/37363635373233343334/eeff74c57593ca38defc902fa6d88005/600/400
Now that I have this URL, I wanna know if it's possible to play the video in android.
I have tried this but it doesn't work because I don't know how to set the swfUrl, pageUrl.....
private static final String MOVIE_URL="rtmp://198.144.153.139:443/kuyo";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.parse(MOVIE_URL);
intent.setData(data);
startActivity(intent);
Thanks in advance....
Add below code into your Activity.java file.
protected void onCreate(Bundle savedInstanceState)
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.videoPlayer);
try {
String link="http://videocloud/video.mp4";
VideoView videoView = (VideoView) findViewById(R.id.myVideoView);
final ProgressBar pbLoading = (ProgressBar) findViewById(R.id.pbVideoLoading);
pbLoading.setVisibility(View.VISIBLE);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(link);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
pbLoading.setVisibility(View.GONE);
}
});
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(this, "Error connecting", Toast.LENGTH_SHORT).show();
}
}
If you don't need MediaController set it to null videoView.setMediaController(null)
I don't think it's enough to just create an intent, you also have to create a context for the video to be played : Like a VideoView object.
The link below has a suggestion for this pattern :
http://androidcodeexamples.blogspot.sg/2011/08/how-to-play-mp4-video-in-android-using.html
Essentially a MediaController object is created with the VideoView object. Then the VideoView is used to start the operation once the URI is set.
Edit :
Probably the main problem though is that your URL contains POST parameters and isn't exactly a unique identifier of a resource (in this case a video file).
The 'swfUrl' and 'pageUrl' parameters are most likely unique to the server that's providing you the page.
You can use Vitamio library for android, where you can set the swfUrl and pageUrl.
Here is a tutorial for it.

Streaming MP4 problem - obvious answer?

I'm a Flash developer by trade, have recently made the jump into Android as the company I work for are moving into apps. I've made a video gallery based on an XML feed, it all works fine until I have to play the movie itself, at which point I get:
Unable to play video. Invalid streaming data.
My gallery items fire up another activity with the .mp4 link as an extra:
public class Video_play extends Activity implements View.OnClickListener {
String vLink;
Uri vid;
VideoView vv;
MediaPlayer mp;
SurfaceHolder holder;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);//Hide app title
Bundle extras = getIntent().getExtras();
if (extras != null) {
vLink = extras.getString("video");
vid = Uri.parse(vLink);
}
setContentView(R.layout.vidplay_layout);
vv = (VideoView)findViewById(R.id.vid_fscreen);
Log.i("Video link is: ",vid+"");
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(vv);
vv.setMediaController(mediaController);
vv.setVideoURI(vid);
vv.start();
}
public void onClick(View v) {
}
}
I've been looking all afternoon and I can't find any straightforward advice on what I'm doing wrong. Any help would be absolutely life-saving, thanks in advance.
What version of Android are you testing it on? HTTP progressive streaming for MP4 video was not fully supported until Android 2.2.
For streaming playback on earlier Android versions you can usually work around this by using post-encoding software like MP4Box to add "hint tracks" to the file:
MP4Box -hint <filename>
http://www.videohelp.com/tools/mp4box

Play Mp4 video from server android

I want to play video of mp4 format and size 4-5Mb from server in streaming mode.I am using sdk version 2.3,on emulator it
gives only sound but not any picture.
I also tested it on devices Samsung(android sdk ver 2.1) and LG optimus(android sdk ver 2.2)
and only get "cannot play video:sorry this video is not valid for streaming to this device" message.
I have searched on this but not getting any solution, if anybody have any solution please help me.Thanks in advance.
Here is my code:
public class ShowVideo extends Activity
{
private static ProgressDialog progressDialog;
public String video_url;
private MediaController mediaController;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.videoalbum);
progressDialog = ProgressDialog.show(ShowVideo.this, "", "Buffering video...", true);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4";
try {
final VideoView videoView =(VideoView)findViewById(R.id.video_viewId);
mediaController = new MediaController(ShowVideo.this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse(video_url);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
progressDialog.dismiss();
videoView.start();
}
});
}catch(Exception e){
progressDialog.dismiss();
System.out.println("Video Play Error :"+e.getMessage());
}
}
You may try these urls (ends with .3gp):
http://daily3gp.com/vids/747.3gp
http://daily3gp/www/vids/juggling_while_on_unicycle.3gp
instead of .mp4 urls:
video_url = "http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4";
On emulator it is difficult to get video played, because it needs really fast computer. Try this link for emulator. Maybe you can get some discrete video view.
http://commonsware.com/misc/test2.3gp
Also in your real devices this link should work if your implementation is proper.
I assume your video using following link
"http://www.letumobi.com/videouploads/cd0a4170-1fb2-4fba-b17c-b5d70b2cd2e7.mp4
is not proper for safe streaming.
You should hint that video or play other hinted videos. I couldn't find any other solution for playing unhinted videos yet.
This link may help.
getting PVMFErrContentInvalidForProgressivePlayback error while playing mp4 files on samsung devices

Categories

Resources