buffercontrol
This commit is contained in:
parent
110f4be0b2
commit
fa314adfc3
5 changed files with 104 additions and 30 deletions
|
@ -47,7 +47,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
AWSCredentials myCredentials;
|
AWSCredentials myCredentials;
|
||||||
AmazonS3 s3client;
|
AmazonS3 s3client;
|
||||||
ProgressBar simpleProgressBar;
|
ProgressBar simpleProgressBar;
|
||||||
int videocache, videotime;
|
int videocache, videotime, buffersize;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -59,6 +59,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
pdfendpoint = getIntent().getStringExtra("pdfendpoint");
|
pdfendpoint = getIntent().getStringExtra("pdfendpoint");
|
||||||
videocache = getIntent().getIntExtra("videocache", 40);
|
videocache = getIntent().getIntExtra("videocache", 40);
|
||||||
videotime = getIntent().getIntExtra("videotime", 1);
|
videotime = getIntent().getIntExtra("videotime", 1);
|
||||||
|
buffersize = getIntent().getIntExtra("buffersize", 2000);
|
||||||
prefix = "";
|
prefix = "";
|
||||||
setContentView(R.layout.activity_bucket_select);
|
setContentView(R.layout.activity_bucket_select);
|
||||||
region = Region.getRegion("us-east-1");
|
region = Region.getRegion("us-east-1");
|
||||||
|
@ -198,6 +199,7 @@ public class BucketSelect extends AppCompatActivity {
|
||||||
intent.putExtra("pdfendpoint", pdfendpoint);
|
intent.putExtra("pdfendpoint", pdfendpoint);
|
||||||
intent.putExtra("videocache", videocache);
|
intent.putExtra("videocache", videocache);
|
||||||
intent.putExtra("videotime", videotime);
|
intent.putExtra("videotime", videotime);
|
||||||
|
intent.putExtra("buffersize", buffersize);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
ArrayList Name;
|
ArrayList Name;
|
||||||
ArrayList Img;
|
ArrayList Img;
|
||||||
MyDbHelper dbHelper;
|
MyDbHelper dbHelper;
|
||||||
int videocache, videotime;
|
int videocache, videotime, buffersize;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -56,22 +56,35 @@ public class MainActivity extends AppCompatActivity {
|
||||||
videocache = (Integer.parseInt(cursor.getString(0)));
|
videocache = (Integer.parseInt(cursor.getString(0)));
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
} catch (Exception e) {
|
if (videocache == 0) {
|
||||||
try {
|
try {
|
||||||
db = dbHelper.getWritableDatabase();
|
db = dbHelper.getWritableDatabase();
|
||||||
db.execSQL("INSERT INTO preferences VALUES ('videocache', '300')");
|
db.execSQL("INSERT INTO preferences VALUES ('videocache', '300')");
|
||||||
videocache = 300;
|
videocache = 300;
|
||||||
db.close();
|
db.close();
|
||||||
} catch (Exception f) {
|
} catch (Exception e) {
|
||||||
db = dbHelper.getWritableDatabase();
|
db = dbHelper.getWritableDatabase();
|
||||||
db.execSQL("CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)");
|
db.execSQL("CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)");
|
||||||
db.execSQL("INSERT INTO preferences VALUES ('videocache', '300')");
|
db.execSQL("INSERT INTO preferences VALUES ('videocache', '300')");
|
||||||
db.execSQL("INSERT INTO preferences VALUES ('videotime', '3')");
|
db.execSQL("INSERT INTO preferences VALUES ('videotime', '3')");
|
||||||
|
db.execSQL("INSERT INTO preferences VALUES ('buffersize', '12000')");
|
||||||
videocache = 300;
|
videocache = 300;
|
||||||
//videotime = 3;
|
//videotime = 3;
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
db = dbHelper.getWritableDatabase();
|
db = dbHelper.getWritableDatabase();
|
||||||
String query = "SELECT value FROM preferences where setting='videotime'";
|
String query = "SELECT value FROM preferences where setting='videotime'";
|
||||||
|
@ -80,13 +93,13 @@ public class MainActivity extends AppCompatActivity {
|
||||||
videotime = (Integer.parseInt(cursor.getString(0)));
|
videotime = (Integer.parseInt(cursor.getString(0)));
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
} catch (Exception e) {
|
if (videotime == 0) {
|
||||||
try {
|
try {
|
||||||
db = dbHelper.getWritableDatabase();
|
db = dbHelper.getWritableDatabase();
|
||||||
db.execSQL("INSERT INTO preferences VALUES ('videotime', '3')");
|
db.execSQL("INSERT INTO preferences VALUES ('videotime', '3')");
|
||||||
videotime = 3;
|
videotime = 3;
|
||||||
db.close();
|
db.close();
|
||||||
} catch (Exception f) {
|
} catch (Exception e) {
|
||||||
db = dbHelper.getWritableDatabase();
|
db = dbHelper.getWritableDatabase();
|
||||||
db.execSQL("CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)");
|
db.execSQL("CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)");
|
||||||
db.close();
|
db.close();
|
||||||
|
@ -104,6 +117,50 @@ public class MainActivity extends AppCompatActivity {
|
||||||
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
db = dbHelper.getWritableDatabase();
|
||||||
|
String query = "SELECT value FROM preferences where setting='buffersize'";
|
||||||
|
Cursor cursor = db.rawQuery(query,null);
|
||||||
|
while (cursor.moveToNext()){
|
||||||
|
buffersize = (Integer.parseInt(cursor.getString(0)));
|
||||||
|
}
|
||||||
|
db.close();
|
||||||
|
if (buffersize == 0) {
|
||||||
|
try {
|
||||||
|
db = dbHelper.getWritableDatabase();
|
||||||
|
db.execSQL("INSERT INTO preferences VALUES ('buffersize', '12000')");
|
||||||
|
buffersize = 12000;
|
||||||
|
db.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
db = dbHelper.getWritableDatabase();
|
||||||
|
db.execSQL("CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)");
|
||||||
|
db.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Toast.makeText(getApplicationContext(),getResources().getString(R.string.broken_database), Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//Toast.makeText(getApplicationContext(),getResources().getString(R.string.media_list_fail), Toast.LENGTH_SHORT).show();
|
||||||
|
finish();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Thread listaccount = new Thread(new Runnable() {
|
Thread listaccount = new Thread(new Runnable() {
|
||||||
|
@ -291,6 +348,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
intent.putExtra("pdfendpoint", pdfendpoint);
|
intent.putExtra("pdfendpoint", pdfendpoint);
|
||||||
intent.putExtra("videocache", videocache);
|
intent.putExtra("videocache", videocache);
|
||||||
intent.putExtra("videotime", videotime);
|
intent.putExtra("videotime", videotime);
|
||||||
|
intent.putExtra("buffersize", buffersize);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ public class MyDbHelper extends SQLiteOpenHelper {
|
||||||
private static final String preftable = "CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)";
|
private static final String preftable = "CREATE TABLE IF NOT EXISTS preferences(setting text UNIQUE, value text)";
|
||||||
private static final String setvideocache = "INSERT INTO preferences VALUES ('videocache', '300')";
|
private static final String setvideocache = "INSERT INTO preferences VALUES ('videocache', '300')";
|
||||||
private static final String setvideotime = "INSERT INTO preferences VALUES ('videotime', '3')";
|
private static final String setvideotime = "INSERT INTO preferences VALUES ('videotime', '3')";
|
||||||
|
private static final String setbuffersize = "INSERT INTO preferences VALUES ('buffersize', '12000')";
|
||||||
//private static final String upgrade = "ALTER TABLE account add column pdfendpoint text";
|
//private static final String upgrade = "ALTER TABLE account add column pdfendpoint text";
|
||||||
private static final int DATABASE_VERSION = 1;
|
private static final int DATABASE_VERSION = 1;
|
||||||
private static final String dbname = "accounts.sqlite3";
|
private static final String dbname = "accounts.sqlite3";
|
||||||
|
@ -22,6 +23,7 @@ public class MyDbHelper extends SQLiteOpenHelper {
|
||||||
db.execSQL(preftable);
|
db.execSQL(preftable);
|
||||||
db.execSQL(setvideocache);
|
db.execSQL(setvideocache);
|
||||||
db.execSQL(setvideotime);
|
db.execSQL(setvideotime);
|
||||||
|
db.execSQL(setbuffersize);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
AWSCredentials myCredentials;
|
AWSCredentials myCredentials;
|
||||||
AmazonS3 s3client;
|
AmazonS3 s3client;
|
||||||
ProgressBar simpleProgressBar;
|
ProgressBar simpleProgressBar;
|
||||||
int videocache, videotime;
|
int videocache, videotime, buffersize;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -65,6 +65,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
treelevel = getIntent().getIntExtra("treelevel", 0);
|
treelevel = getIntent().getIntExtra("treelevel", 0);
|
||||||
videocache = getIntent().getIntExtra("videocache", 40);
|
videocache = getIntent().getIntExtra("videocache", 40);
|
||||||
videotime = getIntent().getIntExtra("videotime", 1);
|
videotime = getIntent().getIntExtra("videotime", 1);
|
||||||
|
buffersize = getIntent().getIntExtra("buffersize", 2000);
|
||||||
setContentView(R.layout.activity_object_select);
|
setContentView(R.layout.activity_object_select);
|
||||||
getSupportActionBar().setTitle(bucket+"/"+prefix);
|
getSupportActionBar().setTitle(bucket+"/"+prefix);
|
||||||
region = Region.getRegion(location);
|
region = Region.getRegion(location);
|
||||||
|
@ -408,6 +409,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
Intent intent = new Intent(this, VideoPlayer.class);
|
Intent intent = new Intent(this, VideoPlayer.class);
|
||||||
intent.putExtra("video_url", url);
|
intent.putExtra("video_url", url);
|
||||||
intent.putExtra("videocache", videocache);
|
intent.putExtra("videocache", videocache);
|
||||||
|
intent.putExtra("buffersize", buffersize);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -450,6 +452,7 @@ public class ObjectSelect extends AppCompatActivity {
|
||||||
intent.putExtra("pdfendpoint", pdfendpoint);
|
intent.putExtra("pdfendpoint", pdfendpoint);
|
||||||
intent.putExtra("videocache", videocache);
|
intent.putExtra("videocache", videocache);
|
||||||
intent.putExtra("videotime", videotime);
|
intent.putExtra("videotime", videotime);
|
||||||
|
intent.putExtra("buffersize", buffersize);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import android.os.PowerManager;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.DefaultLoadControl;
|
||||||
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.PlaybackException;
|
import com.google.android.exoplayer2.PlaybackException;
|
||||||
|
@ -42,9 +44,10 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
LeastRecentlyUsedCacheEvictor evictor;
|
LeastRecentlyUsedCacheEvictor evictor;
|
||||||
StandaloneDatabaseProvider standaloneDatabaseProvider;
|
StandaloneDatabaseProvider standaloneDatabaseProvider;
|
||||||
SimpleCache simpleCache;
|
SimpleCache simpleCache;
|
||||||
int videocache;
|
int videocache, buffersize;
|
||||||
ProgressiveMediaSource mediaSource;
|
ProgressiveMediaSource mediaSource;
|
||||||
|
DefaultLoadControl loadControl;
|
||||||
|
DefaultRenderersFactory renderersFactory;
|
||||||
ExoPlayer player;
|
ExoPlayer player;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,11 +61,17 @@ public class VideoPlayer extends AppCompatActivity {
|
||||||
//Get media url
|
//Get media url
|
||||||
String videoURL = getIntent().getStringExtra("video_url");
|
String videoURL = getIntent().getStringExtra("video_url");
|
||||||
videocache = getIntent().getIntExtra("videocache", 40);
|
videocache = getIntent().getIntExtra("videocache", 40);
|
||||||
|
buffersize = getIntent().getIntExtra("buffersize", 2000);
|
||||||
|
loadControl = new DefaultLoadControl.Builder().setBufferDurationsMs(2000, buffersize, 1500, 2000).build();
|
||||||
|
|
||||||
|
@DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER;
|
||||||
|
|
||||||
|
renderersFactory = new DefaultRenderersFactory(this) .setExtensionRendererMode(extensionRendererMode);
|
||||||
standaloneDatabaseProvider = new StandaloneDatabaseProvider(this);
|
standaloneDatabaseProvider = new StandaloneDatabaseProvider(this);
|
||||||
maxCacheSize = (long)videocache * 1024 * 1024;
|
maxCacheSize = (long)videocache * 1024 * 1024;
|
||||||
playerView = findViewById(R.id.player_view);
|
playerView = findViewById(R.id.player_view);
|
||||||
// creating a variable for exoplayer
|
// creating a variable for exoplayer
|
||||||
player = new ExoPlayer.Builder(this).build();
|
player = new ExoPlayer.Builder(this).setLoadControl(loadControl).build();
|
||||||
evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
|
evictor = new LeastRecentlyUsedCacheEvictor(maxCacheSize);
|
||||||
simpleCache = new SimpleCache(
|
simpleCache = new SimpleCache(
|
||||||
new File(this.getCacheDir(), "media"),
|
new File(this.getCacheDir(), "media"),
|
||||||
|
|
Loading…
Reference in a new issue