Friday, 15 June 2012

Eclipse: Writing Better, Faster Java Documentation

JAutodoc:
 
           I've started using JAutodoc, which is an Eclipse plugin for automatically adding Javadoc to your source code. It helps generate the initial Javadoc for methods which don't have them and can even complete existing Javadoc by adding missing parameters and return types. I have found this plugin very useful in writing documentation fast. 



          Let's say you have the following method which adds two ints:
public int add(int x, int y) {
    return x + y;
}

          To invoke JAutodoc, all you have to do is hit Ctrl+Alt+J inside the method and the following Javadoc template will be automatically generated, which you can then complete.
/**
 * Adds the.
 *
 * @param x the x
 * @param y the y
 * @return the int
 */
public int add(int x, int y) {
    return x + y;
}

          Later on, if you decide to change this method by adding another parameter to it, you can press Ctrl+Alt+J again and JAutoDoc will add the new parameter to the Javadoc but leave the rest of it unchanged.

Enabling Eclipse Javadoc warnings:
           I've also found it useful to turn on Eclipse warnings for missing or malformed Javadoc comments. You can do this by going to Window > Preferences and then selecting Java > Compiler > Javadoc. Tick the box for processing Javadoc comments and select your desired severity levels. I've got mine set to Warnings for everything.

Difference between String and StringBuffer Class

          Java provides the StringBuffer and String classes, and the String class is used to manipulate character strings that cannot be changed. Simply stated, objects of type String are read only and immutable. The StringBuffer class is used to represent characters that can be modified.

          The significant performance difference between these two classes is that StringBuffer is faster than String when performing simple concatenations. In String manipulation code, character strings are routinely concatenated. Using the String class, concatenations are typically performed as follows:
String str = new String ("Konda");
str += "Reddy!!";

          If you were to use StringBuffer to perform the same concatenation, you would need code that looks like this:

StringBuffer str = new StringBuffer ("Konda ");
str.append("Reddy!!");

          Programmers usually assume that the first example above is more efficient (Just like me before some days !!!) because they think that the second example, which uses the append method for concatenation, is more costly than the first example, which uses the + operator to concatenate two String objects.
          The + operator appears innocent, but the code generated produces some surprises. Using a StringBuffer for concatenation can in fact produce code that is significantly faster than using a String. To discover why this is the case, we must examine the generated bytecode from our two examples. The bytecode for the example using String looks like this:

0 new #7
3 dup
4 ldc #2
6 invokespecial #12
9 astore_1
10 new #8
13 dup
14 aload_1
15 invokestatic #23
18 invokespecial #13
21 ldc #1
23 invokevirtual #15
26 invokevirtual #22
29 astore_1

The bytecode at locations 0 through 9 is executed for the first line of code, namely:

String str = new String("Konda ");

Then, the bytecode at location 10 through 29 is executed for the concatenation:

str += "Reddy!!";
   
          Things get interesting here. The bytecode generated for the concatenation creates a StringBuilder object, then invokes its append method: the temporary StringBuilder object is created at location 10, and its append method is called at location 23. Because the String class is immutable, a StringBuilder must be used for concatenation.

          After the concatenation is performed on the StringBuilder object, it must be converted back into a String. This is done with the call to the toString method at location 26. This method creates a new String object from the temporary StringBuilder object. The creation of this temporary StringBuilder object and its subsequent conversion back into a String object are very expensive.

In summary, the two lines of code above result in the creation of three objects:

A String object at location 0
A StringBuilder object at location 10
A String object at location 26

Now, let’s look at the bytecode generated for the example using StringBuffer:
0 new #8
3 dup
4 ldc #2
6 invokespecial #13
9 astore_1
10 aload_1
11 ldc #1
13 invokevirtual #15
16 pop

The bytecode at locations 0 to 9 is executed for the first line of code:
StringBuffer str = new StringBuffer(Konda );

The bytecode at location 10 to 16 is then executed for the concatenation:
str.append("Reddy!!");

          Notice that, as is the case in the first example, this code invokes the append method of a StringBuffer object. Unlike the first example, however, there is no need to create a temporary StringBuilder and then convert it into a String object. This code creates only one object, the StringBuffer, at location 0.

          In conclusion, StringBuffer concatenation is significantly faster than String concatenation. Obviously, StringBuffers should be used in this type of operation when possible. If the functionality of the String class is desired, consider using a StringBuffer for concatenation and then performing one conversion to String.

I found this useful piece of information in sun website…

Hibernate Caching Tutorial

(1) Why Need ?

          While working with Hibernate web applications we will face so many problems in its performance due to database traffic. That to when the database traffic is very heavy . Actually hibernate is well used just because of its high performance only. So some techniques are necessary to maintain its performance. Caching is the best technique to solve this problem. In this article we will discuss about, how we can improve the performance of Hibernate web applications using caching.

          The performance of Hibernate web applications is improved using caching by optimizing the database applications. The cache actually stores the data already loaded from the database, so that the traffic between our application and the database will be reduced when the application want to access that data again. Maximum the application will works with the data in the cache only. Whenever some another data is needed, the database will be accessed. Because the time needed to access the database is more when compared with the time needed to access the cache. So obviously the access time and traffic will be reduced between the application and the database. Here the cache stores only the data related to current running application. In order to do that, the cache must be cleared time to time whenever the applications are changing.

          Hibernate uses two different caches for objects: first-level cache and second-level cache..

1.1) First-level cache

          First-level cache always Associates with the Session object. Hibernate uses this cache by default. Here, it processes one transaction after another one, means wont process one transaction many times. Mainly it reduces the number of SQL queries it needs to generate within a given transaction. That is instead of updating after every modification done in the transaction, it updates the transaction only at the end of the transaction.

1.2) Second-level cache

          Second-level cache always associates with the Session Factory object. While running the transactions, in between it loads the objects at the Session Factory level, so that those objects will available to the entire application, don’t bounds to single user. Since the objects are already loaded in the cache, whenever an object is returned by the query, at that time no need to go for a database transaction. In this way the second level cache works. Here we can use query level cache also. Later we will discuss about it.

(2) Way to Implement It

          Hibernate supports four open-source cache implementations named EHCache (Easy Hibernate Cache), OSCache (Open Symphony Cache), Swarm Cache, and JBoss Tree Cache. Each cache has different performance, memory use, and configuration possibilities.

2.1) 2.1 EHCache (Easy Hibernate Cache) (org.hibernate.cache.EhCacheProvider)

  • It is fast.
  • lightweight.
  • Easy-to-use.
  • Supports read-only and read/write caching.
  • Supports memory-based and disk-based caching.
Does not support clustering.

2.2)OSCache (Open Symphony Cache) (org.hibernate.cache.OSCacheProvider)

  • It is a powerful .
  • flexible package
  • supports read-only and read/write caching.
  • Supports memory- based and disk-based caching.
  • Provides basic support for clustering via either JavaGroups or JMS.

2.3)SwarmCache (org.hibernate.cache.SwarmCacheProvider)

  • is a cluster-based caching.
  • supports read-only or nonstrict read/write caching .
  • appropriate for applications those have more read operations than write operations.

2.4)JBoss TreeCache (org.hibernate.cache.TreeCacheProvider)

  • is a powerful replicated and transactional cache.
useful when we need a true transaction-capable caching architecture .

(3) Caching Strateties
Important thing to remembered while studying this one is none of the cache providers support all of the cache concurrency strategies.

3.1) Read-only

  • Useful for data that is read frequently but never updated.
  • It is Simple .
  • Best performer among the all.
Advantage if this one is, It is safe for using in a cluster. Here is an example for using the read-only cache strategy.
<class name="abc.mutable " mutable="true ">
<cache usage="read-only"/>

</class>

3.2) Read-Write

  • Used when our data needs to be updated.
  • It’s having more overhead than read-only caches.
  • When Session.close() or Session.disconnect() is called the transaction should be completed in an environment where JTA is no used.
  • It is never used if serializable transaction isolation level is required.
  • In a JTA environment, for obtaining the JTA TransactionManager we must specify the property hibernate.transaction.manager_lookup_class.
  • To use it in a cluster the cache implementation must support locking.
Here is an example for using the read-write cache stringategy.
<class name="abc.xyz" .... >
<cache usage="read-write"/>
….
<set name="yuv" ... >
<cache usage="read-write"/>
….
</set>
</class>

3.3) Nonstrict read-write

  • Needed if the application needs to update data rarely.
  • we must specify hibernate.transaction.manager_lookup_class to use this in a JTA environment .
  • The transaction is completed when Session.close() or Session.disconnect() is called In other environments (except JTA) .
Here is an example for using the nonstrict read-write cache stringategy.
                                      
<class name="abc.xyz" .... >
<cache usage=" nonstringict-read-write"/>
….
</class>

3.4) Transactional

  • It supports only transactional cache providers such as JBoss TreeCache.
  • only used in JTA environment.
(4)  Configuration
For configuring cache the hibernate.cfg.xml file is used. A typical configuration file is shown below.
<hibernate-configuration>
        <session-factory>
               ...
               <property name="hibernate.cache.provider_class">
                       org.hibernate.cache.EHCacheProvider
               </property>
               ...
        </session-factory>
</hibernate-configuration>

The name in <property> tag must be hibernate.cache.provider_class for activating second-level cache. We can use hibernate.cache.use_second_level_cache property, which allows you to activate and deactivate the second-level cache. By default, the second-level cache is activated and uses the EHCache.
(5) Advantages

5.1) Performance

Hibernate provides some metrics for measuring the performance of caching, which are all described in the Statistics interface API, in three categories:
  • Metrics related to the general Session usage.
  • Metrics related to the entities, collections, queries, and cache as a whole.
  • Detailed metrics related to a particular entity, collection, query or cache region.

5.2) About Caching

  • All objects those are passed to methods save(), update() or saveOrUpdate() or those you get from load(), get(), list(), iterate() or scroll() will be saved into cache.
  • flush() is used to synchronize the object with database and evict() is used to delete it from cache.
  • contains() used to find whether the object belongs to the cache or not.
  • Session.clear() used to delete all objects from the cache .
  • Suppose the query wants to force a refresh of its query cache region, we should call Query.setCacheMode(CacheMode.REFRESH).
(6) Conclusion
Caching is good one and hibernate found a good way to implement it for improving its performance in web applications especially when more database traffic occurs. If we implement it very correctly, we will get our applications to be running at their maximum capacities. I will cover more about the caching implementations in my coming articles. Try to get full coding guidelines before going to implement this.

Sunday, 10 June 2012

Red5 Streaming

How to install Red5 Streaming server in windows7
Here I am showing Red5 installation with step by steps
1)      First download the Red5 executable file from the official Red5 server, here I downloaded Red5 0.8 version
2)      Then go to that file location install that file , here I show some installation steps








3)      After finishing installation Restart the system(not mandatory) and open the browser . in browser type http://localhost:5080
4)      And then press enter it will show the following image, if it not showed check weather your server is running or not



5)      And then install some demo applications
6)      Here I am installing oflaDemo  application

7)      After installing the oflaDemo application type the following url in browser http://localhost:5080/demos/
8)      Here you will find out the all applications  , go to the oflaDemo application and click view demo link

9)      When you click the view demo link it will open the following window

10)   The click the connect button
11)   Here observe yellow color changed to green color that means your demo application is successfully installed
12)   Then finally see the preinstalled video’s in the oflaDemo application
13)   That’s it you are successfully installed Red5 Server in your system





Then you want to publish any stream from red5 server type the following url http://localhost:5080/demos/publisher.html the following window will be opened.

And then choose your camera for video and choose your audio device for audio… then click the connect button . here I don’t have webcam and headset for that I am not connecting….


Then go to the video tab and choose your video and audio devices
Then go to the publish tab give the name what do u want for your stream, this name will be used to display the stream in your browser
And then click the publish button, that’s it you successfully published rtmp stream with your stream name,





Getting the above rtmp stream in web application
Here I am using struts2 application for that am displaying this rtmp stream in a jsp page,
The jsp  page will be look like this
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
       pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/struts-tags" prefix="s"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script type="text/javascript" src="swfobject.js">
 </script>
</head>
<body>

<div>
 <div id="player">
 Unfortunately you don't have Adobe Flash-Player....
 <a href="http://get.adobe.com/flashplayer/">Click Here to get the Adobe Flash-Player.</a>
 </div><script type="text/javascript">
  var flashvars = {
          file:your stream name,
          streamer:'rtmp://localhost/oflaDemo/',
          bufferlength:'2',
          backcolor:'#000000',
          frontcolor:'#166EBA',
          screencolor:'#999999',
          lightcolor:'#990000',
          autostart:'true',
          repeat:'none',
          stretching:'',
          playlist:'bottom',
          playlistsize:'160',

        };
  var params = { allowfullscreen:'true', allowscriptaccess:'always', wmode:'transparent' };
  var attributes = { id:'player1', name:'player1' };
  swfobject.embedSWF('player.swf','player','384','468','9.0.0','false',flashvars, params, attributes);
 </script>
 </div>
</body>
</html>

HTML5 video tag in my Phone gap Android application


Here I am successfully running HTML5 <video> tag in my Phone gap Android application…
First thing here I succeeded in Android 3.2 version

There are two ways for running video by using <video> tag




1)      By using StrobeMediaPlayer

2)      Without any Player 

1)      Using StrobeMediaPlayer

For that I followed these steps.

1)      Download the StrobeMediaPlayer from the internet
2)      Findout the lib folder in ur downloaded zip file, that lib folder contains two folders (jquery , jscolor) and required js and css files
3)      Then add the lib folder in ur www folder



Required js files:
1)Profiles.js(Required)
2)devicedetection.js(Required)

3)jquery-1.5.1.min.js(Required)

4)jquery-ui-1.8.14.custom.min.js(optional) it displays video time

5)jquery.strobemediaplaybackhtml5.js(Required)

6)StrobeMediaPlayer.js(Required)

index.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Device Detection Test</title>
<style type="text/css">
body {
 font-family: sans-serif;
}

.movie {
 width: 100%;
 clear: both;
}

.movie div.thumb {
 float: left;
 margin-right: 10px;
 cursor: pointer;
 border: solid 1px blue;
}

.movie div.details {
 width: 100%;
 height: 100%;
}

.movie div.details p.title {
 font-weight: bold;
 cursor: pointer;
}

.movie div.details p.desc {
 font-weight: normal;
}
</style>
<link type="text/css" rel="stylesheet"
 href="lib/jquery.strobemediaplaybackhtml5.css" />

<script type="text/javascript" src="lib/profiles.js"></script>
<script type="text/javascript" src="lib/devicedetection.js"></script>
<script type="text/javascript" src="lib/jquery/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.14.custom.min.js"></script>
<script type="text/javascript"
 src="lib/jquery.strobemediaplaybackhtml5.js"></script>
<script type="text/javascript" src="lib/StrobeMediaPlayer.js"></script>
<script>
 var movies = [
   {
    "flashvars" : {
     "poster" : "http://www.osmf.org/dev/1.6gm/images/poster1.png",
     "src" : "http://players.edgesuite.net/videos/big_buck_bunny/bbb_448x252.mp4"
    },
    "element" : "clipContainer0"
   }, ];
 $(function() {
  for (i = 0; i < movies.length; i++) {
   strobeMediaPlayback.flashvars(movies[i]["flashvars"]);
   strobeMediaPlayback.draw(movies[i]["element"]);
  }
 });
</script>
</head>
<body>
 <div>Strobe Media Playback</div>
 <div id="movie0" class="movie">
  <div class="thumb">
   <div id="clipContainer0"></div>
  </div>
  <div class="details">
   <p class="title">Video One</p>
   <p class="desc">Video one description.</p>
  </div>
 </div>

</body>
</html>



----------------------END OF index.html --------------------

Then add these two classes in your source folder

1)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package com.phonegap.plugins.aVideo;

import org.json.JSONArray;
import org.json.JSONException;
import vPlayer.VideoPlayer;
import android.content.Intent;
import android.util.Log;
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;

public class AVideo extends Plugin {

    /**
     * Executes the request and returns PluginResult.
     *
     * @param action        The action to execute.
     * @param args          JSONArry of arguments for the plugin.
     * @param callbackId    The callback id used when calling back into JavaScript.
     * @return              A PluginResult object with a status and message.
     */
    public PluginResult execute(String action, JSONArray args, String callbackId) {
        PluginResult.Status status = PluginResult.Status.OK;
        String result = "";

        try {
            if (action.equals("showVideo")) {
                result = this.showVideo(args.getString(0));
                if (result.length() > 0) {
                    status = PluginResult.Status.ERROR;
                }
            }
            return new PluginResult(status, result);
        } catch (JSONException e) {
            return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
        }
    }

    /**
     * Identifies if action to be executed returns a value and should be run synchronously.
     *
     * @param action    The action to execute
     * @return          T=returns value
     */
    public boolean isSynch(String action) {
        return false;
    }

    /**
     * Called by AccelBroker when listener is to be shut down.
     * Stop listener.
     */
    public void onDestroy() {
    }

    //--------------------------------------------------------------------------
    // LOCAL METHODS
    //--------------------------------------------------------------------------

    /**
     * Display a video with the specified name.
     *
     * @param videoName     The video to load.
     * @return              "" if ok, or error message.
     */
    public String showVideo(String videoName) {
     Log.d("logicmax", videoName);
     try {
            Intent intent = null;
                intent = new Intent().setClass(this.ctx, VideoPlayer.class);
               
                intent.putExtra("Nme", videoName);
                
            this.ctx.startActivity(intent);
            return "";
        } catch (android.content.ActivityNotFoundException e) {
            Log.d("logicmax","error");
         return e.toString();
            
        }
    }

}


--------------------------END OF AVIDEO.JAVA-----------------------

2)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package vPlayer;

import nl.webkrackt.test.R;
import android.app.Activity;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;


public class VideoPlayer extends Activity implements   MediaPlayer.OnErrorListener, MediaPlayer.OnCompletionListener {
  private VideoView mVideoView;
  private String Chemin;
  private int videoPosition;
  
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
   
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  
  setContentView(R.layout.lv);
  mVideoView = (VideoView)findViewById(R.id.videoView);
     mVideoView.setOnErrorListener(this);
     mVideoView.setOnCompletionListener(this);

        Bundle returnData = (Bundle) getLastNonConfigurationInstance();
     if (returnData == null) {
      Bundle Params = getIntent().getExtras ();
      String pth = Params.getString("Nme");
      if(pth!=null)
       Chemin = "android.resource://"+getPackageName() +"/raw/" + pth;
      else
       finish();
       
       MediaController mediaController = new MediaController(this);
       mediaController.setAnchorView(mVideoView);
       mVideoView.setVideoURI(Uri.parse(Chemin));
       mVideoView.setMediaController(mediaController);
       mVideoView.requestFocus();
       //mVideoView.start();
     
     }
     else
     {
             Chemin = returnData.getString("LOCATION");
             videoPosition = returnData.getInt("POSITION");
             MediaController mediaController = new MediaController(this);
             mediaController.setAnchorView(mVideoView);          
       mVideoView.setMediaController(mediaController);
             mVideoView.setVideoURI(Uri.parse(Chemin));
             mVideoView.seekTo(videoPosition);
             
     }
 }
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
     if (keyCode == KeyEvent.KEYCODE_BACK ) {
         finish();
         return true;
     }
     return super.onKeyDown(keyCode, event);
 }


 @Override
 protected void onPause() {
  super.onPause();

  if (mVideoView!=null) {
    synchronized (mVideoView) {
     mVideoView.pause();     
   }
   
  }
  
 }
  @Override
  protected void onResume() {
   super.onResume();

   if (mVideoView!=null) {
     synchronized (mVideoView) {
      mVideoView.start();  
      setVisible(true);      
    }
    
   }

  
 }
  @Override
     public Object onRetainNonConfigurationInstance() {         
         videoPosition = mVideoView.getCurrentPosition();
         Bundle data = new Bundle();
         data.putString("LOCATION", Chemin);
         data.putInt("POSITION", videoPosition);
         return data;
     }
  
  @Override
  protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
    videoPosition = mVideoView.getCurrentPosition();
          Bundle data = new Bundle();
          data.putString("LOCATION", Chemin);
          data.putInt("POSITION", videoPosition);
  }
  
     public boolean onError(MediaPlayer player, int arg1, int arg2) {         
         finish();
         return false;
     }
  public void onCompletion(MediaPlayer mp) {
      finish();
  }
}


-------------------*END OF VIDEOPLAYER.JAVA*--------------------

Then add these two line in your Activity class after the super.loadUrl();

WebSettings settings = appView.getSettings();
settings.setPluginState(PluginState.ON);

4)Copy the below code and paste in StrobeMediaPlayer.js

var strobeMediaPlayback = function () {
 alert("StrobeMediaPlayBack first");
 var settings = {
  "tablet": {
   "startSize": {"width":480, "height":268},
   "wmode": "direct"
  },
  "smartphone": {
   "startSize": {"width":120, "height":67},
   "wmode": "direct"
  },
  "default": {
   "startSize": {"width":480, "height":268},
   "wmode": "direct"
  }
 };
 
 var flashvars = {};
 
 function getSettingByDeviceType(setting, deviceType, defaultValue) {
  if (deviceType in settings) {
   return (settings[deviceType][setting] ? settings[deviceType][setting] : defaultValue);
  }
  else {
   return (settings["default"][setting] ? settings["default"][setting] : defaultValue);
  }
 }
 
 return { 
  settings: function(object) {
   settings = $.extend(true, settings, object);
  },
  flashvars: function(object) {
   flashvars = $.extend(true, flashvars, object);
  },
  draw: function(element) {
   if (element && flashvars && flashvars["src"]) {
    var agent = window.location.hash.replace(/^#/, "");

    function onDeviceDetection(device) {
     var startSize = getSettingByDeviceType("startSize", device.getProfile().type, "");
  var html5divs = '<div class="html5player">' + '<div class="errorwindow"></div>' +'<div class="controls">' +'<div class="icon playtoggle">Play/Pause</div>' +'<div class="timestamp current">0:00</div>' +'<div class="progress">' +'<a class="slider"></a>' +'<div class="tracks">' +'<div class="seeking"></div>' +  '<div class="played"></div>' +'<div class="buffered"></div>' + '</div>' +'</div>' +'<div class="timestamp duration">0:00</div>' +'<div class="icon fullview">Full View</div>' +'</div>' +'<video width="500" height="400" preload="none" poster="' + flashvars["poster"] + '">' +'<source src="http://players.edgesuite.net/videos/big_buck_bunny/bbb_448x252.mp4" />' +'</video>'+ '</div>';

$("#" + element).html(html5divs);
$("#" + element + " .html5player").strobemediaplaybackhtml5();
  }
new DeviceDetection(agent).addCallback(onDeviceDetection).addProfiles(profiles).detect();
   }
  }
 }
}();


---------------------END OF StrobeMediaPlayer.js---------------------------

5)AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="nl.webkrackt.test"
    android:versionCode="1"
    android:versionName="1.0" >
    
    <supports-screens
                android:largeScreens="true"
                android:normalScreens="true"
                android:smallScreens="true"
                android:resizeable="true"
                android:anyDensity="true"
                />
        <uses-permission android:name="android.permission.CAMERA" />
        <uses-permission android:name="android.permission.VIBRATE" />
        <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
        <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.RECEIVE_SMS" />
        <uses-permission android:name="android.permission.RECORD_AUDIO" />
        <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
        <uses-permission android:name="android.permission.READ_CONTACTS" />
        <uses-permission android:name="android.permission.WRITE_CONTACTS" />   
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <uses-sdk android:minSdkVersion="7" />

    <application android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:hardwareAccelerated="true" >
        <activity
            android:name=".VideoTestActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.phonegap.DroidGap" android:label="@string/app_name"
   android:configChanges="orientation|keyboardHidden" >
   <intent-filter>
   </intent-filter>
  </activity>
  <activity android:name="vPlayer.VideoPlayer" android:label="@string/app_name"></activity>
    </application>

</manifest>


-------------------END OF ANDROIDMANIFEST.XML-------------------------


Observe above xml file addded android:hardwareAccelerated="true"  attribute in ur < application> tag



1) Without any Player


Here I don’t want to use any player for running html5 video tag for that I do the following steps

1)change the androidManifest.xml file

a)      In androidManifest.xml file i added the android:hardwareAccelerated=”true” for <application> tag
b)      Added code for doing PluginState True in Java file
The following code is added in java file after the super.loadUrl();

WebSettings settings = appView.getSettings();
settings.setPluginState(PluginState.ON);