android video download

Is there a way i can download large video files to my android app?
network.download crashes the app with 10-40 mb. video files.
[import]uid: 13632 topic_id: 15648 reply_id: 315648[/import]

I suspect it is crashing because there is not enough storage space on the Android device to hold the file. Note that I have not confirmed this for myself; this is merely my suspicion. Of course it is not okay for the app to crash in this case, so I’ll write up a bug report for this.

Since the video file is so large, perhaps it is better to stream the video from the Internet instead of downloading the file? Our media.show() function definitely supports this. Alternatively, you can embed the video file within your app and play it locally. This way, the user can’t install the app unless they have enough storage on his/her device. [import]uid: 32256 topic_id: 15648 reply_id: 57830[/import]

Hi Joshua

Thank you for your reply.

Yes I thougt storage was the problem too, but I tested it on 6-7 different android devices, with plenty of available storage both internal and external.

So my suspicion is that it tries to store the whole download in ram before saving it to the storage, and the crash is because it runs out of memory.

I get this logcat output when it crashes:

09-28 08:58:16.890: ERROR/dalvikvm-heap(10367): Out of memory on a 16001399-byte allocation.
09-28 08:58:16.949: ERROR/AndroidRuntime(10367): FATAL EXCEPTION: main
09-28 08:58:16.949: ERROR/AndroidRuntime(10367): java.lang.OutOfMemoryError

I know about the stream/embed alternatives and they work very well, but the project is not really well suited for streaming. Embedding is not really an option because android market only accepts 50 mb apk’s.
[import]uid: 13632 topic_id: 15648 reply_id: 57927[/import]

I tried the sample Streaming Video example and it works fine
with your “Corona-iPhone.m4v” from your server. However, when
I put that same video on our server it fails.

Ultimately we need to stream 30MB-50MB videos. Thoughts?

Thanks,
Chris [import]uid: 93878 topic_id: 15648 reply_id: 58046[/import]

You’re right. I confirmed it by setting up an app to download the Corona SDK, which is over 50 MB. Our Android code is wrongly buffering the download to memory instead of streaming it to file.

This issue just made it near the top of my list. So you’ll likely hear from me again soon. Thanks for reporting this. [import]uid: 32256 topic_id: 15648 reply_id: 58049[/import]

Hi Joshua

Great thanks.

Would you be so kind to post a reply to this thread,
when you find some kind of solution?

Then I will notice it :slight_smile: [import]uid: 13632 topic_id: 15648 reply_id: 58068[/import]

Will do! :slight_smile: [import]uid: 32256 topic_id: 15648 reply_id: 58075[/import]

The crash has been fixed! I also discovered that network.download() wrongly blocks the UI thread and prevents multiple async downloads from occurring at the same time. I fixed that issue too.

These fixes will be made available in the next daily build, which is available to you if you are a paid subscriber here…

https://developer.anscamobile.com/downloads/daily-builds/
[import]uid: 32256 topic_id: 15648 reply_id: 58124[/import]

Hi Joshua

That’s absolutely brilliant.
We are just about to release a bunch of apps that is supposed to use this.

Thanks a lot for fixing this so soon. [import]uid: 13632 topic_id: 15648 reply_id: 58133[/import]

@Joshua

by the way would it be possible to do a small adjustment to the daily build orientation fix you did here:

https://developer.anscamobile.com/forum/2010/11/13/play-video-android

it would be very nice if we were able to decide whether we wan’t the video to change orientation or not… by adding a boolean to the parameters for media.playVideo.

something like this:

media.playVideo( path [, baseSource], showControls, listener [, changeOrientation] )

Thanks again. [import]uid: 13632 topic_id: 15648 reply_id: 58135[/import]

I agree that the playVideo needs better options for this. In fact, I think I would prefer it to be handled more like this…

local options =  
{  
 showControls = false,  
 supportedOrientations = {"portrait", "portraitUpsideDown", "landscapeRight", "landscapeLeft"},  
 listener = myListener  
}  
media.playVideo("MyMovie.mp4", options)  

The “supportedOptions” would then list out all of the orientations the video player would support, and if more than one orientation is listed, then it would support orientation changes on the fly. This would then mimic how it is handled in our “build.settings” file.

That said, we can’t work on this just yet, but I will add it to our wish-list. This something I would have to coordinate with one of our iOS developers so that there is feature parity between both Android and iOS… and our iOS developers are very busy making awesome stuff at the moment.
[import]uid: 32256 topic_id: 15648 reply_id: 58231[/import]

Hi,

Sorry for replying in this old thread, but is there any news about this idea with local options for media.playVideo?! [import]uid: 123747 topic_id: 15648 reply_id: 94472[/import]

marijo,

We haven’t made any changes to the media.playVideo(). But what I’ve written up above is on our wish-list.

In the meantime, we have another solution that might work for you. We’ve create a brand new function called native.newVideo() which returns a display object containing a video player. With this, you can position it any way that you want and inside your own app. Please see the following links for more details.
http://blog.anscamobile.com/2012/01/using-the-new-native-web-video-apis/
http://developer.anscamobile.com/reference/index/nativenewvideo

Also, please note that native.newVideo() is only supported on iOS. It is not supported on Android or the Corona Simulator yet. This is because it is still in BETA and is only available in the newest daily builds (not in a release version). [import]uid: 32256 topic_id: 15648 reply_id: 94568[/import]

Tnx for info, but android is the problem. My app is in portrait orientation, and media streaming should be in landscape orientation. On iPhone media player can be rotated but, on android it stays to portrait orientation.

Is it possible to change media player orientation on android devices? [import]uid: 123747 topic_id: 15648 reply_id: 94718[/import]

If you use release build 704, then the video player will support all orientations just like it does on iOS. I believe the later daily builds (sometime in December) fixed the video player’s centering problem as well that was present in 704. [import]uid: 32256 topic_id: 15648 reply_id: 95248[/import]

Currently my release build is 768, and I can’t go back to 704 (widgets changes and optimisations).

So I’m, kinda, stuck in middle of nowhere. :frowning: [import]uid: 123747 topic_id: 15648 reply_id: 95307[/import]

The Android video player in build 768 definitely supports all orientations. I can’t reproduce your issue. You’re not hacking the APK’s AndroidManifest.xml via apktool are you?

Also, try running sample app “Media\StreamingVideo” that is included with the Corona SDK on your Android device. it too should support all orientations. [import]uid: 32256 topic_id: 15648 reply_id: 95313[/import]

Hi,
I have tried sample app “Media\StreamingVideo”.
Same thing - only portrait orientation.
Here is an image:

Tested device:
Samsung Galaxy S
Model Number: GT-I9000
Firmware version: 2.3.3
Kernel version: 2.6.35.7-I9000BOJV9-CL404614
Build number: GINGERBREAD.BOJV9 [import]uid: 123747 topic_id: 15648 reply_id: 95392[/import]

I just tried the same sample app “Media\StreamingVideo” on my Samsung Galaxy S2 and the orientation is changing for me when I hold the device in portrait or landscape.

I can think of only one other thing that could cause this. I’m thinking your phone (as in the device itself) has its “Auto-rotate screen” option disabled. Which means all of your apps will not support change of rotation and will have a fixed orientation at all times. You can verify this by doing the following:

  1. Press the Home button to go to the home screen.
  2. Press the “Menu” button to show the popup menu.
  3. Press the “Settings” button.
  4. Select “Display” from the list.
  5. Verify that the “Auto-rotate screen” option is checked.
    [import]uid: 32256 topic_id: 15648 reply_id: 95534[/import]

Yap, that’s it. Now media player changes his orientation.

Thank you very much, Joshua. [import]uid: 123747 topic_id: 15648 reply_id: 95678[/import]