How to play a local mp4 video with phonegap/HTML5 on android

  • 2
  • Question
  • Updated 6 years ago
  • Answered
Hi,
I really hope you can help me with this as nothing seems to be working on android (4.0.4)
I tried using the HTML5 video tag which doesn't work, even if I include a command to start playing it manually via button.
I also tried http://simonmacdonald.blogspot.de/201...

https://github.com/jaeger25/Html5Video
Is working but it needs to be in the apk package so useless for me as my video is in the camera folder.

Any ideas how to play my video?
Photo of Jonas Paczia

Jonas Paczia

  • 3 Posts
  • 1 Reply Like

Posted 7 years ago

  • 2
Photo of Hyginus Ugwumba

Hyginus Ugwumba

  • 1206 Posts
  • 42 Reply Likes
Topic likely related to PhoneGap Framework or programming, rather then Build service. If you haven't receive anymore feedback from the community, kindly please post and continue to discuss at our framework forum or at stackoverflow

Framework Forum: https://groups.google.com/forum/?from...
Stackoverflow: http://stackoverflow.com/questions/ta...
PhoneGap Doc. http://docs.phonegap.com/en/2.9.0/cordova_media_media.md.html#Media

*To get the most out of framework support, consider our PhoneGap Paid Support option: http://phonegap.com/support/

Thanks


Photo of Will Collins

Will Collins

  • 18 Posts
  • 0 Reply Likes
Any update on this?
Photo of Will Collins

Will Collins

  • 18 Posts
  • 0 Reply Likes
Did anyone ever figure out how to do this, the local video playback with Android?
Photo of Jonas Paczia

Jonas Paczia

  • 3 Posts
  • 1 Reply Like
Kind of, for me it's working if you delete the line
<script src="phonegap.js"></script>
on the HTML page you want to play the video with.

So whenever you are using a HTML video-tag on your page delete the import of "phonegap.js" and the video should be able to play!
Photo of Will Collins

Will Collins

  • 18 Posts
  • 0 Reply Likes
How are you calling the local video? I'd really appreciate this if you could let me know.
Photo of Gotta Getmedat

Gotta Getmedat

  • 39 Posts
  • 0 Reply Likes
I'm using Video!
It's been 3 to 6 months of living hell and I'm probably not out of the woods yet.
Total disaster area (when talking compatibility across many devices).
I suggest you open links to YouTube instead (for now in a legacy reality).
Speaking particularly to Android and it's browsers.
Everything would have been fine if the player in Android I tested showed the darn buttons play of the controls in the corners correctly.
Other issues are things hard to recollect...
Loss of events when in full screen (as if it's a new element)? [Of course having no way to get Events to transfer in Dom is a major flaw, and likely part of that problem]
Not able to update sources properly (without replacing video tag basically or something like that to patch more failings).
the true videoWidth&videoHeight often wrong (in the later reload case) so total custom code needed to resize from the parent div to the window size in pixels from percentage (a recurring theme in responsive design these days [Text sizes, rounded shapes to name a few more torturous examples of html5 falling way short of modern needs {locked out of history is another major bitch}].)

I can't help you more then to say it's one of the most problematic (but important) areas I've discovered. Oh wait I can here...

Your probably missing the sources in triplicate. The 'video' tag will work though.
Also they will only work from a remote server no video from local files allowed for some reason I guess to keep the apps small.
<video id="yPlayer" class="yPlayer" poster="http://yDom.top/Vids/Vid-01.png" preload="preload" name="yPlayer" />
<source type="video/mp4" src="http://yDom.top/Vids/Vid-01.mp4" />
<source type="video/ogg" src="http://yDom.top/Vids/Vid-01.ogv" />
<source type="video/webm" src="http://yDom.top/Vids/Vid-01.webm" />
</video>

Your suppose to include a codec to in theory. Also onError etc. recommended.
Photo of Will Collins

Will Collins

  • 18 Posts
  • 0 Reply Likes
I understand, it has been a living hell for me, too. What's worse is that I had local video working a few weeks ago, on both iOS and Android from the build service. It was great and I moved on to other functionality for the app. When I stumbled upon the video not working anymore I was aghast. This is truly terrible, like hitting a moving target with code. I know something changed in the build service, but I can't get anyone from Adobe to look at the issue.

Unfortunately, I simply *can't* point to youtube; My client needs the app to work without WiFi.
Photo of Jonas Paczia

Jonas Paczia

  • 3 Posts
  • 1 Reply Like
For me src="file:///mnt/sdcard/DCIM/Camera/video.mp4" worked out.
This links to the video "video.mp4" in the standard camera folder of Android (4.0.4), probably it's always the same for all versions!
You always need "file:///mnt/sdcard/" unless it's on an external SD-Card, which would be "file:///mnt/sdcard0/".
If you need to figure the path out check ES File Explorer File Manager with enabled expert settings

It may be also useful for you to test your HTML pages via copying the HTML file on the device and open it with your browser. This way you can check if the source is available.
For my tests Chrome was the best because it has more functionality than the default one. But that depends what you're doing....
At least it's possible to play .mp4 video files this way using HTML5
Photo of Gotta Getmedat

Gotta Getmedat

  • 39 Posts
  • 0 Reply Likes
Okay well I've done extensive rebuilding even though there's no room in an app for video.
This is where the file codeBase appears but it spins on Android ICS when trying to play the video. Confirming the weak link, and that local video is not possible (unless you have it on only certain devices) Remember it works great from the remote server, if your clients Android clients are working that way then great!
Good Luck!
file:///data/data/com.domain.appname/hydra_app/Videos/VidAnim-01.ext
Photo of Ryan Archer

Ryan Archer

  • 2 Posts
  • 0 Reply Likes
Anyone got this solution working when locally building apps with Cordova and CLI? I have tried using external links instead of local files packaged with the app (I gave up).

It's a major pain in the
Photo of Ryan Archer

Ryan Archer

  • 2 Posts
  • 0 Reply Likes
Amazing what some decent sleep can do. I used the answer given at this stackoverflow posting http://stackoverflow.com/questions/19... and it finally worked in my testing device. Emulator is a turd and not all that helpful.
Photo of Kevin Kong

Kevin Kong

  • 5 Posts
  • 0 Reply Likes
I tried it and it worked in Android 4.3 but failed in 4.4. Have you ever succeeded in 4.4? Or any advice regarding 4.4?
Photo of ismael jimoh

ismael jimoh

  • 4116 Posts
  • 192 Reply Likes
You have asked this question here.

Closing this now.

If you have any questions follow the above issue you opened.

Thanks.

This conversation is no longer open for comments or replies.