Skip to main content
zulin
Participating Frequently
September 5, 2012
Question

How can I play video on Android using native player?

  • September 5, 2012
  • 1 reply
  • 11709 views

Is there a way to tell android to open my mp4 (either in assets or on external sd)  with it's native video player?

Just like if I tap this (mp4) file in any android file manager.

reasons:

1 - I don't want to write my own player (especially when I have one built in)

2 - I assume playback experience may be better when playing large file NOT through the AIR.

So, can I  make something like "NativeApplication.execute(pathToMp4)"?

This topic has been closed for replies.

1 reply

sinious
Legend
September 5, 2012

Have you tried a StageWebView? I haven't touched Android much lately but I do a lot of iOS apps and iOS gives standard (quicktime/html5-esque) controls to any mp4 played directly in a StageWebView, with a fullscreen button. Just note on Android after AIR 3.0 device acceleration must be enabled.

zulin
zulinAuthor
Participating Frequently
September 6, 2012

Yes I tried. Maybe in iOS it is handled better but on Asus tablet I only got video controls displayed and sound was playing (while there was no video). This is not codec problem because I used mp4 recorded by device and its native player played it correctly. Same results (sound played, no video though) I got when tried to open same html in native browser (so maybe this has something to do with it).

It's sad I have to dance with playback and controls in flash rather than using native ...

sinious
Legend
September 10, 2012

Video plays OK in native browser (if opened from any file manager). To ensure this is not codecs problem I used video which was recorded by device assuming that built-in browser should be able to play video recorded by built-in camera app. Native player plays video great (just like my other video which I got elsewhere).

And then when I try to play video using StageWebView it shows me controls and even kind of plays it but I see no video, only sound.

To test it I created simple video.html

<html><head><title>My Player title</title></head><body>

<video id="player" autobuffer width="1280" height="500" onclick="this.play();">

<source src="video1.mp4">

</video>

</body></html>

which had video1.mp4 next to it

File Manager -> Browser ---> plays OK

AS -> StageWebView ---> plays only sound


Check the hardware acceleration mode you have set. Try to use "direct" acceleration as this will choose between GPU and CPU to render and is most compatible. The setting is in the XML file generated for the app:

<!-- The render mode for the app (either auto, cpu, gpu, or direct). Optional. Default auto -->

<renderMode>direct</renderMode>

And no the device is absolutely not guaranteed to record compatible video at all. Browsers go by browser standards and video recording goes via manufacturer hardware and software limits, features and compatibility. It entirely depends on what you're doing with the video and the mode it is recorded in. If the user checks off the record CIF MMS compatible video and records in that it will not be visible to many browsers. Audio is almost always recorded in ultra-light mp3 or aac so that's why you hear it.

Android allows you to install many different browsers. Did you install any or set any other browser as the alternate default browser? When you run the video from a file manager you may be running an alternate, capable browser for the codec. AIR may use the native built-in browser. Also it may not load the video into a browser for playback at all as I would suspect a video would be mapped to the devices default media player and not a browser at all. Unless you're able to select the video and explicitly tell it to open in a browser I feel you're actually looking at the video in the "Video" app of your device, which will be compatible with the codec.

A simple way to check browser compatibility is to copy the video to your computer, upload it to a web server and see how it plays on various desktop browsers. If any of them have black video and only play sound, you know it's a codec issue.