2016-12-05 2 views
0

IP 카메라에서 실시간 비디오를 스트리밍하는 응용 프로그램을 만들려고합니다. click 를하지만 응용 프로그램을 시작하려고 할 때이 예외가 있습니다 :이 튜토리얼을하고 있어요컴파일 응용 프로그램을 컴파일하는 중 오류가 발생했습니다.

Android.Views.InflateException : 바이너리 XML 파일 라인 # 1 : 바이너리 XML 파일 라인 # 1 : 오류 팽창 클래스 com.camera.simplemjpeg.MjpegView

나는이 문제를 해결하려고 노력했지만 나는 정말 그것을 해결하는 방법을 모른다 .. 내 코드 :

MainActivity.cs :

using System; 
using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 
using Com.Camera.Simplemjpeg; 
using System.Threading.Tasks; 

namespace IP_Cam_View 
{ 
    [Activity(Label = "IP_Cam_View", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivity : Activity 
    { 
     //MjpegView instance 
     private MjpegView mv = null; 
     //Play button 
     Button button = null; 
     //UI EditText with URL 
     EditText txturl = null; 
     //Streaming URL 
     String URL = "http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?resolution=640x480"; 
     //Layout sizes for video view 
     private int width = 640; 
     private int height = 480; 
     //Suspendign straming bool variable 
     private bool suspending = false; 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 
      // Set our view from the "main" layout resource 
      SetContentView(Resource.Layout.Main); 
      //initialize mjpeg view with UI Android XML 
      mv = FindViewById<MjpegView>(Resource.Id.mv); 
      //check if the instance is valid 
      if (mv != null) 
      { 
       //set the resolution of streaming 
       mv.SetResolution(width, height); 
      } 
      //assignation of UI items 
      button = FindViewById<Button>(Resource.Id.myButton); 
      txturl = FindViewById<EditText>(Resource.Id.editText1); 
      //button click event 
      button.Click += delegate 
      { 
       //take URL from txturl(EditText) field 
       URL = txturl.Text; 
       //Begin a task method to streaming 
       BeginStreaming(URL); 
      }; 
      //Begin a task method to streaming 
      BeginStreaming(URL); 
     } 
     //OnResume Method check if streaming is suspending and continue with the streaming 
     protected override void OnResume() 
     { 
      base.OnResume(); 
      if (mv != null) 
      { 
       if (suspending) 
       { 
        BeginStreaming(URL); 
        suspending = false; 
       } 
      } 
     } 
     //OnDestroy Free Memory of a streaming 
     protected override void OnDestroy() 
     { 
      base.OnDestroy(); 
      if (mv != null) 
      { 
       mv.FreeCameraMemory(); 
      } 
     } 
     //OnPause put the streaming suspending 
     protected override void OnPause() 
     { 
      base.OnPause(); 
      if (mv != null) 
      { 
       if (mv.IsStreaming) 
       { 
        mv.StopPlayback(); 
        suspending = true; 
       } 
      } 
     } 
     /// <summary> 
     /// Begins the streaming. 
     /// with a parallel task we start the streaming 
     /// </summary> 
     /// <param name="url">URL. 
     public void BeginStreaming(string url) 
     { 
      //Create a new task with a MjpegInputStream return 
      Task.Factory.StartNew(() => 
      { 
       try 
       { 
        //inicialize streaming 
        return MjpegInputStream.Read(url); 
       } 
       catch (Exception e) 
       { 
        //if something was wrong return null 
        Console.WriteLine(e.Message); 
       } 
       return null; 
      }).ContinueWith((t) => 
      { 
       //check if the result was fine 
       mv.SetSource(t.Result); 
       if (t.Result != null) 
       { 
        //set skip to result 
        t.Result.SetSkip(1); 
        Title = "Connected"; 
       } 
       else 
       { 
        Title = "Disconnected"; 
       } 
       //set display mode 
       mv.SetDisplayMode(MjpegView.SizeFullscreen); 
       //set if you need to see FPS 
       mv.ShowFps(false); 
      }); 
     } 
    } 
} 

그리고 Main.axml : 어떤 답변

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/editText1" 
     android:text="http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?resolution=640x480" /> 
    <Button 
     android:id="@+id/myButton" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="watch" /> 

    <com.camera.simplemjpeg.MjpegView 
     android:id="@+id/mv" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="1" /> 

</LinearLayout> 

감사합니다!

답변

0

글쎄, 해당 jar 파일에 빌드 작업이 "Embeddedjar"로 설정되어 있는지 확인하십시오. JDK 1.8을 아직 설치하지 않았다면 설치하십시오. 그건 내가 그 오류를 해결하는 데 도움이. 불행히도 여전히 스트림 재생에 문제가 있습니다. 어쩌면 너는 운이 좋을거야 .-.

+0

글쎄, 전혀 문제가없는 것 같습니다. –

관련 문제