내 안드로이드 응용 프로그램에서 MP4를 재생하려고하는데 어떤 이유로 작동하지 않습니다.안드로이드 응용 프로그램에서 비디오를 재생하는 중 오류가 발생했습니다.
I가 안드로이드에 대한 모든 형식 및 파일 containters을 보았다:이 비디오를 작동하게하는 데 사용할 수있는 온라인 또는 오프라인 컨버터가 있는가 https://developer.android.com/guide/appendix/media-formats.html
?
내 홈페이지 :
public class MainActivity extends AppCompatActivity {
LinearLayout screen;
Handler handler;
int fadeTime;
Button BtnTextColor;
Random rnd = new Random();
Button BackgroundButton;
final Context context = this;
private Button button;
private EditText result;
Button ChangeName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView mediaPlayer = (VideoView)findViewById(R.id.videoView1);
String uriPath2 = "android.resource://com.example.toyo.playvideo/"+R.raw.video;
Uri uri2 = Uri.parse(uriPath2);
mediaPlayer.setVideoURI(uri2);
mediaPlayer.requestFocus();
mediaPlayer.start();
fadeTime = -20; //text fade timer
android.support.v7.app.ActionBar theactionbar = getSupportActionBar(); //ActionBar
screen = (LinearLayout) findViewById(R.id.screen); //Background Screen
//hide action bar (top)
theactionbar.hide();
//fades from white to blue
ObjectAnimator colorFade = ObjectAnimator.ofObject(screen, "backgroundColor", new ArgbEvaluator(), Color.argb(0, 0, 0, 0), 0xff7F87CF);
colorFade.setDuration(3000);
colorFade.start();
//fade text
Animation animFadeIn;
animFadeIn = AnimationUtils.loadAnimation(this, R.anim.text_fade);
animFadeIn.start();
animFadeIn = new AlphaAnimation(0.0f, 1.0f);
animFadeIn.setDuration(8000);
animFadeIn.start();
DelayedDialog();
// Button Listeners
BackgroundButton = (Button) findViewById(R.id.Change_Background);
ChangeName = (Button) findViewById(R.id.ChangeWelcome);
ChangeName.setOnClickListener(new View.OnClickListener() {
//Enter Name
@Override
public void onClick(View v) {
Dialog();
}
});
}
public void onRadioButtonClicked(View view) {
// R. Button checked
final boolean checked = ((RadioButton) view).isChecked();
// Which R. Button was checked
switch (view.getId()) {
//Rapid R.Button selected
case R.id.BackgroundRapidChange:
if (checked) {
BackgroundButton.setOnClickListener(new View.OnClickListener() {
//Rapid Background Switch
@Override
public void onClick(View v) {
RapidBackgroundColor();
BtnTextColor = (Button) findViewById(R.id.Change_Text);
final TextView tt = (TextView) findViewById(R.id.Welcome_Text);
//Rapid Text Switch
BtnTextColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RapidTextColor();
}
});
}
});
if(checked == false) {
Dialog();
}
}
break;
//Slow R. Button selected
case R.id.BackgroundSlowChange:
if (checked) {
//Slow Background Switch
BackgroundButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
SlowBackgroundChangeColor();
BtnTextColor = (Button) findViewById(R.id.Change_Text);
//Slow Text Switch
BtnTextColor.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SlowTextColor();
}
});
}
});
}
break;
}
}
public void SlowBackgroundChangeColor() {
int Changecolor = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
ObjectAnimator ChangecolorFade = ObjectAnimator.ofObject(screen, "backgroundColor", new ArgbEvaluator(),
Color.argb(Changecolor, Changecolor, Changecolor, Changecolor), Changecolor);
//slow change
ChangecolorFade.setDuration(2000);
ChangecolorFade.start();
}
public void SlowTextColor() {
final TextView tt = (TextView) findViewById(R.id.Welcome_Text);
int Changecolor = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
int ChangecolorText = Color.argb(225, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
ValueAnimator colorAnim = ObjectAnimator.ofInt(tt, "textColor", ChangecolorText, Changecolor);
colorAnim.setDuration(2000);
colorAnim.setEvaluator(new ArgbEvaluator());
}
public void RapidTextColor() {
final TextView tt = (TextView) findViewById(R.id.Welcome_Text);
Random rnd = new Random();
int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
tt.setTextColor(color);
}
public void RapidBackgroundColor() {
int Changecolor = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
ObjectAnimator ChangecolorFade = ObjectAnimator.ofObject(screen, "backgroundColor", new ArgbEvaluator(),
Color.argb(Changecolor, Changecolor, Changecolor, Changecolor), Changecolor);
//fast change
screen.setBackgroundColor(Changecolor);
}
public void Dialog(){
button = (Button) findViewById(R.id.buttonPrompt);
result = (EditText) findViewById(R.id.editTextResult);
LayoutInflater li = LayoutInflater.from(context);
View promptsView = li.inflate(R.layout.dialog, null);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
context);
final AlertDialog.Builder noText = new AlertDialog.Builder(
context);
alertDialogBuilder.setView(promptsView);
final EditText userInput = (EditText) promptsView
.findViewById(R.id.editTextDialogUserInput);
alertDialogBuilder
.setCancelable(false)
.setPositiveButton("OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int id) {
if(userInput.getText().length() ==0){
Dialog();
}
TextView ChangeWelcomeText = (TextView) findViewById(R.id.Welcome_Text);
ChangeWelcomeText.setText("Welcome \n" + userInput.getText());
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
}
public void DelayedDialog() {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
Dialog();
}
}, 4000);
}
}
그리고 이것은 내 레이아웃 XML입니다 :
<RadioGroup android:id="@+id/backgroundoption"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton android:id="@+id/BackgroundRapidChange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="Rapid" />
<RadioButton android:id="@+id/BackgroundSlowChange"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="Slow" />
</RadioGroup>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton android:id="@+id/Auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="Auto" />
<RadioButton android:id="@+id/Manual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onRadioButtonClicked"
android:text="Manual" />
</RadioGroup>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Change Background"
android:id="@+id/Change_Background"
android:layout_centerHorizontal="true"
android:gravity="center|bottom"
android:layout_gravity="center_horizontal|center"
>
</Button>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Change Text"
android:id="@+id/Change_Text"
android:layout_centerHorizontal="true"
android:gravity="center|bottom"
android:layout_gravity="center_horizontal|center"
>
</Button>
<Button
android:id="@+id/ChangeWelcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Change Name"
>
</Button>
<TextView
android:id="@+id/Welcome_Text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="80dp"
android:text="Welcome"
android:textColor="@color/white"
android:gravity="center_horizontal"
>
</TextView>
<Button
android:id="@+id/buttonPrompt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Please Enter your Name" />
<EditText
android:id="@+id/editTextResult"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</EditText>
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
그것은 조금 길고 아주 지저분한, 그것은 내 첫 안드로이드 앱
입니다
"결코 놀지 않을 것입니다"라는게 무슨 뜻이야? logcat의 모든 오류 메시지? 22 : –
내가지고있어 오류가 '07-09 04 12.590 12805-12805/geepool.myfirstandroidapp의 E/MediaPlayer를 : 자막 컨트롤러가 있어야 이미 – deathsonic
을 set' 내가 사용하고있는 코드는 다음과 같습니다 ' VideoView mVideoView2 = (VideoView) findViewById (R.id.videoView1); String uriPath2 = "android.resource : //com.example.toyo.playvideo/"+ R.raw.video; Uri uri2 = Uri.parse (uriPath2); mVideoView2.setVideoURI (uri2); mVideoView2.requestFocus(); mVideoView2.start(); ' – deathsonic