<string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
<string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
<string name="action_stream_file">Stream file with external player</string>
- <string name="stream_expose_password">May expose password?</string>
+ <string name="stream_expose_password">Do you want to stream this file with an external app?\n\nCAUTION: This may expose your password!</string>
</resources>
releaseResources(false); // release everything except MediaPlayer
try {
-// if (mFile == null) {
-// Toast.makeText(this, R.string.media_err_nothing_to_play, Toast.LENGTH_LONG).show();
-// processStopRequest(true);
-// return;
-
if (mAccount == null) {
Toast.makeText(this, R.string.media_err_not_in_owncloud, Toast.LENGTH_LONG).show();
processStopRequest(true);
createMediaPlayerIfNeeded();
mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
String url = mFile.getStoragePath();
- // Streaming is not possible right now
+
if (url == null || url.length() <= 0) {
url = AccountUtils.constructFullURLForAccount(this, mAccount) + mFile.getRemotePath();
}
import com.owncloud.android.files.FileMenuFilter;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
+import com.owncloud.android.media.MediaService;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
return true;
}
case R.id.action_stream_file: {
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setMessage("May expose password?")
- .setPositiveButton("Stream", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- Account account = ((FileActivity)mContainerActivity).getAccount();
- Context context = MainApp.getAppContext();
- String uri = PreviewMediaFragment.generateUrlWithCredentials(account, context, mTargetFile);
-
- Intent i = new Intent(android.content.Intent.ACTION_VIEW);
- i.setData(Uri.parse(uri));
- startActivity(i);
-
-// Intent i = new Intent(Intent.ACTION_VIEW);
-// i.setComponent(new ComponentName("org.videolan.vlc", "org.videolan.vlc.gui.video.VideoPlayerActivity"));
-// i.setData(Uri.parse(uri));
-// startActivity(i);
- }
- })
- .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- // User cancelled the dialog
- }
- });
- builder.show();
+ Account account = ((FileActivity)mContainerActivity).getAccount();
+ Context context = MainApp.getAppContext();
+ String uri = PreviewMediaFragment.generateUrlWithCredentials(account, context, mTargetFile);
+ MediaService.streamWithExternalApp(uri, getActivity()).show();
return true;
}
// decide grid vs list view
OwnCloudVersion version = AccountUtils.getServerVersion(
- ((FileActivity) mContainerActivity).getAccount());
+ ((FileActivity)mContainerActivity).getAccount());
if (version != null && version.supportsRemoteThumbnails() &&
imagesCount > 0 && imagesCount == filesCount) {
switchToGridView();
if (mAccount == null) {
throw new IllegalStateException("Instanced with a NULL ownCloud Account");
}
-// if (!file.isDown()) {
-// throw new IllegalStateException("There is no local file to preview");
-// }
-
}
else {
file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
* <p/>
* Just starts the playback.
*
- * @param vp {@link MediaPlayer} instance performing the playback.
+ * @param vp {@link MediaPlayer} instance performing the playback.
*/
@Override
public void onPrepared(MediaPlayer vp) {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD) {
mVideoPreview.pause();
- } else {
+ }
+ else {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1) {
// mVideePreview.pause() is not enough
*/
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
-// if (mVideoPreview.getWindowToken() != null) {
- // try to open with another app
-// try{
-// AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
-// builder.setMessage("May expose password?")
-// .setPositiveButton("Stream", new DialogInterface.OnClickListener() {
-// public void onClick(DialogInterface dialog, int id) {
-// Intent i = new Intent(android.content.Intent.ACTION_VIEW);
-// i.setData(Uri.parse(mUri));
-// startActivity(i);
-// }
-// })
-// .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
-// public void onClick(DialogInterface dialog, int id) {
-// // User cancelled the dialog
-// }
-// });
-// builder.show();
-
- MediaService.streamWithExternalApp(mUri, getActivity()).show();
-
-// }
-// catch (ActivityNotFoundException e){
-// Intent i = new Intent(android.content.Intent.ACTION_VIEW);
-// i.setData(Uri.parse(mUri));
-// startActivity(i);
-// }
-// }
-// }
+ MediaService.streamWithExternalApp(mUri, getActivity()).show();
return true;
-
}
}
mVideoPlayer.setVideoPath(file.getStoragePath());
} else {
- // not working yet
String url;
-// try {
-// url = AccountUtils.constructFullURLForAccount(this, getAccount()) + file.getRemotePath();
- url = PreviewMediaFragment.generateUrlWithCredentials(getAccount(), getApplicationContext(), getFile());
- mVideoPlayer.setVideoURI(Uri.parse(url));
-// } catch (AccountNotFoundException e) {
-// onError(null, MediaService.OC_MEDIA_ERROR, R.string.media_err_no_account);
-// }
+ url = PreviewMediaFragment.generateUrlWithCredentials(getAccount(), getApplicationContext(), getFile());
+ mVideoPlayer.setVideoURI(Uri.parse(url));
}
// create and prepare control panel for the user