-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TimedText demo & Video buffer demo
- Loading branch information
Crossle Song
committed
Aug 13, 2013
1 parent
d3e183b
commit 7920cb2
Showing
12 changed files
with
570 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<SurfaceView android:id="@+id/surface" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" | ||
/> | ||
|
||
<TextView android:id="@+id/sub1" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/res_audio" | ||
android:layout_alignParentBottom="true" | ||
android:layout_centerInParent="true" | ||
/> | ||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<io.vov.vitamio.widget.CenterLayout | ||
android:id="@+id/dd" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<io.vov.vitamio.widget.VideoView | ||
android:id="@+id/surface_view" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" /> | ||
</io.vov.vitamio.widget.CenterLayout> | ||
|
||
<TextView | ||
android:id="@+id/subtitle_view" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:layout_centerInParent="true" | ||
android:text="@string/res_audio" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<io.vov.vitamio.widget.CenterLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" > | ||
|
||
<io.vov.vitamio.widget.VideoView | ||
android:id="@+id/buffer" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_centerHorizontal="true" | ||
android:layout_centerVertical="true" /> | ||
</io.vov.vitamio.widget.CenterLayout> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_centerInParent="true" | ||
android:orientation="horizontal" > | ||
|
||
<ProgressBar | ||
android:id="@+id/probar" | ||
style="?android:attr/progressBarStyleLarge" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" /> | ||
|
||
<TextView | ||
android:id="@+id/download_rate" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="" /> | ||
|
||
<TextView | ||
android:id="@+id/load_rate" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:text="" /> | ||
</LinearLayout> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
vitamio-sample/src/io/vov/vitamio/demo/MediaMetadataRetrieverDemo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
156 changes: 156 additions & 0 deletions
156
vitamio-sample/src/io/vov/vitamio/demo/MediaPlayerSubtitle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/* | ||
* Copyright (C) 2013 yixia.com | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.vov.vitamio.demo; | ||
|
||
import java.io.IOException; | ||
|
||
import io.vov.vitamio.LibsChecker; | ||
import io.vov.vitamio.MediaPlayer; | ||
import io.vov.vitamio.MediaPlayer.OnPreparedListener; | ||
import io.vov.vitamio.MediaPlayer.OnTimedTextListener; | ||
|
||
import android.os.Bundle; | ||
import android.os.Environment; | ||
import android.app.Activity; | ||
import android.graphics.PixelFormat; | ||
import android.view.SurfaceHolder; | ||
import android.view.SurfaceHolder.Callback; | ||
import android.view.SurfaceView; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
public class MediaPlayerSubtitle extends Activity implements Callback, OnPreparedListener, OnTimedTextListener { | ||
|
||
SurfaceView splayer; | ||
SurfaceHolder sholder; | ||
TextView tv; | ||
private MediaPlayer mediaPlayer; | ||
private String path = ""; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
if (!LibsChecker.checkVitamioLibs(this)) | ||
return; | ||
setContentView(R.layout.subtitle1); | ||
tv = (TextView) findViewById(R.id.sub1); | ||
splayer = (SurfaceView) findViewById(R.id.surface); | ||
sholder = splayer.getHolder(); | ||
sholder.setFormat(PixelFormat.RGBA_8888); | ||
sholder.addCallback(this); | ||
} | ||
|
||
private void playVideo() { | ||
try { | ||
if (path == "") { | ||
// Tell the user to provide an audio file URL. | ||
Toast.makeText(MediaPlayerSubtitle.this, "Please edit MediaPlayer Activity, " + "and set the path variable to your media file path." + " Your media file must be stored on sdcard.", Toast.LENGTH_LONG).show(); | ||
return; | ||
} | ||
mediaPlayer = new MediaPlayer(this); | ||
mediaPlayer.setDataSource(path); | ||
mediaPlayer.setDisplay(sholder); | ||
mediaPlayer.prepareAsync(); | ||
mediaPlayer.setOnPreparedListener(this); | ||
|
||
mediaPlayer.setOnTimedTextListener(this); | ||
|
||
// TODO Auto-generated catch block | ||
} catch (IllegalArgumentException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} catch (IllegalStateException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} catch (SecurityException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
// TODO Auto-generated catch block | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
@Override | ||
public void surfaceCreated(SurfaceHolder holder) { | ||
// TODO Auto-generated method stub | ||
playVideo(); | ||
} | ||
|
||
@Override | ||
public void surfaceDestroyed(SurfaceHolder holder) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
private void startVPback() { | ||
|
||
mediaPlayer.start(); | ||
} | ||
|
||
@Override | ||
public void onPrepared(MediaPlayer arg0) { | ||
|
||
// TODO Auto-generated method stub | ||
startVPback(); | ||
mediaPlayer.addTimedTextSource(Environment.getExternalStorageDirectory() + "/12.srt"); | ||
mediaPlayer.setTimedTextShown(true); | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
// TODO Auto-generated method stub | ||
super.onPause(); | ||
relaMediaPlay(); | ||
} | ||
|
||
private void relaMediaPlay() { | ||
// TODO Auto-generated method stub | ||
if (mediaPlayer != null) { | ||
mediaPlayer.release(); | ||
mediaPlayer = null; | ||
} | ||
|
||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
// TODO Auto-generated method stub | ||
super.onDestroy(); | ||
relaMediaPlay(); | ||
|
||
} | ||
|
||
@Override | ||
public void onTimedText(String text) { | ||
// TODO Auto-generated method stub | ||
tv.setText(text); | ||
} | ||
|
||
@Override | ||
public void onTimedTextUpdate(byte[] pixels, int width, int height) { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.