How play video from sd-card cordova phonegap - android

I am new to cordova phonegap, i want to browse the video from sdcard and play the video in android. I have tried by hard coding the file uri,
<video id="1" width="100%" >
<source src="file:///storage/0/emulated/videos/video3.mp4" type="video/mp4" />
</video>
it is not working.
Please help me.

Did you try to call
var myVideo = document.getElementById("1");
myVideo.load();
in your script?

Related

HTML code to run a local video file working fine on windows but not on android

<!DOCTYPE html>
<html>
<body>
<h3>Basic English Lesson Listen & Speak</h3>
<video width="320" height="240" controls>
<source src="BASIC ENGLISH LESSON 14.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
</body>
</html>
The video file is in the same directory folder as my html file.
I need guidance on why its not working on my android 11 OS tablet.
You have to call video.play() in order to play videos in android
Try this:
<!DOCTYPE html>
<html>
<body>
<h3>Basic English Lesson Listen & Speak</h3>
<video width="320" height="240" controls>
<source src="BASIC ENGLISH LESSON 14.mp4">
Your browser does not support the video tag.
</video>
</body>
<script>
var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false);
</script>
</html>
It is about which browser you using ,
If your browser running on older version then you found this type of error.
I suggesting you for use google chrome I think it will work fine.
or else you have to give full path of video if in your android drive.

MP4 does not play from Azure Blob on Android

I have the following video HTML:
<video id="player_a" class="video-js" controls preload="auto" title="Home video" width="640" poster="~/Assets/img/video_poster_full.jpg" data-setup="{}">
<source src="https://#####.blob.core.windows.net/video/homepage-video.mp4" type="video/mp4">
<source src="https://#####.blob.core.windows.net/video/homepage-video.webm" type="video/webm">
<source src="https://#####.blob.core.windows.net/video/homepage-video.ogv" type="video/ogg" />
<p class="vjs-no-js">
To view this video please enable JavaScript, and consider upgrading to a web browser that
supports HTML5 video
</p>
</video>
On Android, this video does not play from the webpage. But as soon as I change my video host from the Azure Blob to my own private server (http://myserver.net/images/homepage-video.mp4), it streams fine.
I notice that if I just go directly to the URL of the .mp4, it does not load from Blob (but does from my private server). I also notice that the .webm does load okay from Blob but for some reason, my video is not falling back to that format.
Are there any settings I need to change in Azure Blob to allow .mp4 to be streamed differently? Or what am I doing wrong that is not causing the video to fall back to .webm?
The permissions on your blob will need to be public to make sure that you can access the content without a key. You can check this in the properties of the container.
In the documentation you can find an excellent post on how to set these permissions up.

Android app not playing mp3 (locally stored mp3s)

I have a phonegap app and I'm trying to play mp3's which are stores in the app's folder like this:
--App Root
-- audio
-- mp3s
--Mp3's are all here
Now, the problem is only with Android because it works fine in IOS. On android I'm getting the audio player but no sound is coming out.
Here is the code:
//JS
var
audiofile = 'audio/mp3s/'+result.text+'en.mp3';
//HTML
<audio class="audioPlayer" controls>
<source src="'+audiofile+'" type="audio/mpeg">
</audio>
How can I fix this?
On android you may need to prefix the path to the file with "/android_asset"
So use "/android_asset/audio/mp3s/" as the base directory.
Try to debug the app with chrome Inspect Devices (DevTools little menu), and see if there are any errors.

How to play videos in android from raw folder and htm file

How can I play videos from a raw folder in an .htm file on android?
Neither of these code snippets work for me:
<video id="video" controls>
<source src="android.resource://tutorials.bodybuilding/raw/smit.mp4" type="video/mp4">
</video>
or
<video id="video" controls>
<source src="url('android.resource://tutorials.bodybuilding/raw/smit.mp4')" type="video/mp4">
</video>
According to reading file in assets or raw folder in Android I guess your addresses are wrong. You should consider what
Uri.parse("android.resource://tutorials.bodybuilding/" + R.raw.csgsmit);
returns for every of your videos and place it into html OR at runtime load html into a String and replace every address using such method and then load modified html using Webview.loadData() or Webview.loadDataWithBaseUrl() passing a modified html (a resluting String).

Embed video in html using ftp url [duplicate]

in video tag src we are trying to give src as a ftp resource its not picking it up. Can somebody give some direction on that.
<video src='ftp://server/pqr.mp4' />
I suspect that's because to allow efficient usage, the browser makes HTTP range requests, which are part of HTTP, not FTP. FTP is a pretty old protocol, and isn't really appropriate here for lots of reasons (no range requests, basic/no caching info, etc).
something like this
<video width="320" height="240" controls="controls">
<source src="http://movie.mp4" type="video/mp4" />
<source src="http://movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
The issue here is :
Loading an FTP sub-resource through an HTTP / S page is not allowed
This is for security issues, see https://bugzilla.mozilla.org/show_bug.cgi?id=1361848
Use this code:
<video width="320" height="240" controls="controls">
<source src="http://movie.mp4" type="video/mp4" />

Categories

Resources