playing video

11 views
Skip to first unread message

eyurdakul

unread,
Feb 8, 2010, 8:48:24 AM2/8/10
to phonegap
Hi everybody,

i am developing for android 1.5 and debugging on my HTC hero. does
anybody have an example of playing video using javascript. I am unable
to use video tags since eclipse won't launch my app cause the video
tag not recognized. I've tried :
navigator.media.startPlaying("file:///sdcard/1206/test.mp4", 1,
function(){}, function(){});
navigator.media.startPlaying("1206/test.mp4", 1, function(){},
function(){});

i've also tried to append the video tag after load but it causes app
to crash. What am i doing wrong?
Thanks in advance, ejder

eyurdakul

unread,
Feb 8, 2010, 9:32:17 AM2/8/10
to phonegap
movie = new Media("/sdcard/1206/test.mp4", function(d){alert(d);},
function(e){alert(e);});
movie.play();

i've tried this too with no success.

eyurdakul

unread,
Feb 9, 2010, 9:53:00 AM2/9/10
to phonegap
well, media object doesn't do anything in my version cause the needed
interface is not implementedin droidgap.java see,

private void bindBrowser(WebView appView)
{

gap = new PhoneGap(this, appView);
geo = new GeoBroker(appView, this);
accel = new AccelListener(this, appView);
//i put this to add the capability but i will have to write my own
functions to create a surface, play the video on it, delete surface
and focus back to the webview
media = new AudioHandler("record.mp3", this);
launcher = new CameraLauncher(appView, this);
// This creates the new javascript interfaces for PhoneGap
appView.addJavascriptInterface(gap, "DroidGap");
appView.addJavascriptInterface(geo, "Geo");
appView.addJavascriptInterface(accel, "Accel");
//added
appView.addJavascriptInterface(media, "Media");
appView.addJavascriptInterface(launcher, "GapCam");
}

Now the question is, will my webview keep running while i watch the
video and will i have access to the phonegap javascript functions
after focusing back to the web view. We will see.

eyurdakul

unread,
Feb 10, 2010, 5:48:05 AM2/10/10
to phonegap
Ok,
so far i've created videolauncher class and added javascript
interface:
appView.addJavascriptInterface(accel, "Accel");

VideoLauncher doesn't do anything but calling a function of gap and
has the same structure as GeoListener etc..

second, i've created a VideoHandler class which is similar to
camerapreview class. gap.startVideo calls this class so the function's
direction is javascript->videolauncher->droidgap and finally oncreate
event of videohandler class.

This class creates a surface view, mediaplayer, mediacontroller and
supposed create a surface and insert in the main view. But somehow,
the application just crashes when i add this functionality. I've
followed exactly same way as the camerapreview and cameralauncher
classes and edited the droidgap class as needed. I was able to call
the videohandler's play function but at that point, the application
crashes.(on onsurfacecreated event actually). Any idea?

Reply all
Reply to author
Forward
0 new messages