How to play video in a local file system (for example: res / a.3gp) using VideoView. I need some sample code. I am trying to play as below:
import android.app.Activity; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class videoSample extends Activity { /** Called when the activity is first created. */ String path="D:/mApp2/videoSample/res/drawable-hdpi/adf.mp4"; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView videoView = (VideoView) findViewById(R.id.VideoView01); MediaController mediaController = new MediaController(this); mediaController.setMediaPlayer(videoView); videoView.setVideoPath(path); videoView.setMediaController(mediaController); videoView.requestFocus(); videoView.start(); mediaController.show(); } }
I get an error because the video cannot be played. Can someone help me in solving this problem? Thanks at Advance.
String path = "D: /mApp2/videoSample/res/drawable-hdpi/adf.mp4";
In Android, there is no D: drive. Android is not Windows.
I used this line and worked for me:
private String srcPath = "android.resource://com.myapp/raw/videofile";
then ...
myVideoView.setVideoURI(Uri.parse(srcPath));
where com.myapp is the main application package
hope this helps!
Afaik cannot play videos from the internal storage of applications; see Can video video play videos stored in the internal storage?
I ran into a similar problem and was already looking for it.
http://www.anddev.org/multimedia-problems-f28/videoview-cannot-play-video-from-internal-storage-t16636.html
http://groups.google.com/group/android-developers/browse_thread/thread/a01d415c8e48e0d3
The workaround is to temporarily copy the video to the SD card and play it there.
Source: https://habr.com/ru/post/1763426/More articles:How to get reusable sleeping criteria.? - hibernateGriddata with cubic interpolation method Returns NaN - matlabВызов простого веб-сервиса (.asmx файла) из AJAX и JQuery с использованием JSON-parse error - jsonGet xhr object in vb.net when ajax call fails - jqueryAndroid application runs twice in the main menu - androidHTML column with multiple columns - javascriptsame origin policy in external js file - javascriptCalling Mathematica from OCaml - wolfram-mathematicaphp does not remove 775 dir chmod - phpWCF services. Create multiple instances at startup? - wcfAll Articles