2012年5月31日 星期四

Play Video on Android

!!! IMPORTANT !!!
*** Ti.Media.createVideoPlayer only accept url of externalStorageDirectory !!!  It can now. 2013.11.27

it doesn't play video in ApplicationDataDirectory. It can now. 2013.11.27

Android supported video format:

For android,
Ti.Filesystem.externalStorageDirectory = appdata://
for file in this directory, file.getNativePath = file:///mnt/sdcard/{appID}/{filename}
equivalent in adb shell :  /sdcard/{appID}/{filename}


Problem: play sound but black screen
video format: H.264, 480x270, Millions AAC,  1 channel, 44100Hz, FPS 25, DataRate ~247 kbits/s

Sample video format provided by Appcelerator (the basketball clip)
video format: MPEG-4,  368x208,  Millions AAC,  2 channel, 44100Hz, FPS 25, DataRate ~567 kbits/s

Findings:
seems related to VideoPlayer codings but not the video clip itself

Example (correct one)
var activeMovie = Ti.Media.createVideoPlayer({    url: videofile.nativePath,  //or can be an URL http://.....mp4    mediaType: Ti.Media.VIDEO_MEDIA_TYPE_VIDEO,    backgroundColor:'#111',    scalingMode: Ti.Media.VIDEO_SCALING_ASPECT_FIT,   mediaControlStyle: Ti.Media,VIDEO_CONTROL_FULLSCREEN});win.add(activeMovie);activeMovie.addEventListener('complete', function(){    activeMovie.hide();    win.close();}activeMovie.play();win.addEventListener('close', function(){   activeMovie.stop();}

沒有留言:

張貼留言