Mjpeg Class embedded in an xml ?

All your problems with Audio, Video and Images.

Mjpeg Class embedded in an xml ?

Postby coersum » Thu Nov 10, 2011 7:24 am

Hi,

I have been trying to get an Mjpeg class to show into a xml display for a while and I just can't get it to work :(
if I use the View of the class it works, but I don't know out to make it show in the xml display.

Here is what I have done:
1. Created a new 2.2 project called myProject with activity "myActivity" and package name "com.myProject01"
3. Created 2 files in "com.myProject01" package: "MjpegInputStream.java" and "MjpegView.java" (in attached eclipse project file).
4. So far everything works (since I didn't yet use the Mjpeg java's). It's just a normal starter app.

5. Changed MyActivity.java to:
Code: Select all
package com.myproject01;

import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import com.myproject01.MjpegView;
import com.myproject01.MjpegInputStream;

public class MyActivity extends Activity {
   private MjpegView mv;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
       
        //sample public cam
        String URL = "http://webcam.universeum.se/mjpg/video.mjpg";

        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                             WindowManager.LayoutParams.FLAG_FULLSCREEN);
       
       
        mv = new MjpegView(this);
        //setContentView(R.layout.main);
        setContentView(mv);
       
        mv.setSource(MjpegInputStream.read(URL));
        mv.setDisplayMode(MjpegView.SIZE_STANDARD);
        mv.showFps(true);
       
    }
   
   public void onPause() {
      super.onPause();
      mv.stopPlayback();
   }   
}

Now at this point, everything works, we have the camera showing with fps at the bottom right. Now I would like to find out how to show that camera (mv) into an xml display (or how to add elements to the current display).

I tried this:
add to the main.xml:
Code: Select all
<view
  class="com.myproject01.MjpegView"
  android:id="@+id/mv"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  />


and change myActivity.java to
Code: Select all
setContentView(R.layout.main);
//setContentView(mv);

aka I reset the "setContentView" to my main.xml instead of "mv" (the MjpegView). This is clearly not working, I just get a blank screen. I also tried with SurfaceView instead of View but nothing.

Now I just have a blank screen with my "hello world, myActivity01" at the top. Yes my internet permission is on.
I am hoping someone out there can help me out. I have a public ip cam in there but I tested with my own and it works the same way (and doesn't work the same way too).

Thank you in advance.
Attachments
myProject01.rar
This is the entire project in the non-working state, to see it work disable "setContentView(R.layout.main);" and enable "setContentView(mv);" in myActivity.java
(58.28 KiB) Downloaded 25 times
coersum
Freshman
Freshman
 
Posts: 2
Joined: Tue Nov 08, 2011 3:49 pm

Top

Re: Mjpeg Class embedded in an xml ?

Postby narenayak » Mon Nov 21, 2011 11:56 am

made some changes have a look .not an expert just trying out
thankyou
narenayak
Attachments
myProject01.rar
(76.47 KiB) Downloaded 44 times
narenayak
Freshman
Freshman
 
Posts: 2
Joined: Wed Oct 19, 2011 11:18 am

Top

Return to Multimedia Problems

Who is online

Users browsing this forum: No registered users and 4 guests