| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.pm.PackageManager; | 8 import android.content.pm.PackageManager; |
| 9 import android.media.MediaMetadataRetriever; | 9 import android.media.MediaMetadataRetriever; |
| 10 import android.net.ConnectivityManager; | 10 import android.net.ConnectivityManager; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 MediaMetadataRetriever retriever = new MediaMetadataRetriever(); | 93 MediaMetadataRetriever retriever = new MediaMetadataRetriever(); |
| 94 try { | 94 try { |
| 95 Uri uri = Uri.parse(url); | 95 Uri uri = Uri.parse(url); |
| 96 String scheme = uri.getScheme(); | 96 String scheme = uri.getScheme(); |
| 97 if (scheme == null || scheme.equals("file")) { | 97 if (scheme == null || scheme.equals("file")) { |
| 98 File file = new File(uri.getPath()); | 98 File file = new File(uri.getPath()); |
| 99 String path = file.getAbsolutePath(); | 99 String path = file.getAbsolutePath(); |
| 100 if (file.exists() && (path.startsWith("/mnt/sdcard/") || | 100 if (file.exists() && (path.startsWith("/mnt/sdcard/") || |
| 101 path.startsWith("/sdcard/") || | 101 path.startsWith("/sdcard/") || |
| 102 path.startsWith(PathUtils.getExternalStorageDirectory())
)) { | 102 path.startsWith(PathUtils.getExternalStorageDirectory())
|| |
| 103 path.startsWith(context.getCacheDir().getAbsolutePath())
)) { |
| 103 retriever.setDataSource(path); | 104 retriever.setDataSource(path); |
| 104 } else { | 105 } else { |
| 105 Log.e(TAG, "Unable to read file: " + url); | |
| 106 return new MediaMetadata(durationInMilliseconds, width, heig
ht, success); | 106 return new MediaMetadata(durationInMilliseconds, width, heig
ht, success); |
| 107 } | 107 } |
| 108 } else { | 108 } else { |
| 109 HashMap<String, String> headersMap = new HashMap<String, String>
(); | 109 HashMap<String, String> headersMap = new HashMap<String, String>
(); |
| 110 if (!TextUtils.isEmpty(cookies)) { | 110 if (!TextUtils.isEmpty(cookies)) { |
| 111 headersMap.put("Cookie", cookies); | 111 headersMap.put("Cookie", cookies); |
| 112 } | 112 } |
| 113 if (!TextUtils.isEmpty(userAgent)) { | 113 if (!TextUtils.isEmpty(userAgent)) { |
| 114 headersMap.put("User-Agent", userAgent); | 114 headersMap.put("User-Agent", userAgent); |
| 115 } | 115 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 129 height = Integer.parseInt(videoHeight); | 129 height = Integer.parseInt(videoHeight); |
| 130 success = true; | 130 success = true; |
| 131 } catch (IllegalArgumentException e) { | 131 } catch (IllegalArgumentException e) { |
| 132 Log.e(TAG, "Invalid url: " + e); | 132 Log.e(TAG, "Invalid url: " + e); |
| 133 } catch (RuntimeException e) { | 133 } catch (RuntimeException e) { |
| 134 Log.e(TAG, "Invalid url: " + e); | 134 Log.e(TAG, "Invalid url: " + e); |
| 135 } | 135 } |
| 136 return new MediaMetadata(durationInMilliseconds, width, height, success)
; | 136 return new MediaMetadata(durationInMilliseconds, width, height, success)
; |
| 137 } | 137 } |
| 138 } | 138 } |
| OLD | NEW |