public ITitaniumSound createSound(String url) { TitaniumSound s = null; url = TitaniumUrlHelper.buildAssetUrlFromResourcesRoot(getActivity(), url); Uri uri = Uri.parse(url); s = new TitaniumSound(this, uri); return s; }
public ITitaniumVideo createVideoPlayer(final String jsonOptions) { ITitaniumVideo result = null; String errorCallback = null; try { JSONObject options = new JSONObject(jsonOptions); try { errorCallback = options.getString("error"); // callbacks will be added on JS side. to track } catch (JSONException e2) { Log.d(LCAT, "error callback not available"); } String url = null; try { url = options.getString("contentURL"); Uri uri = Uri.parse(url); String scheme = uri.getScheme(); if (scheme == null || scheme.length() == 0 || (scheme == null && !(new File(url).exists()))) { uri = Uri.parse(TitaniumUrlHelper.buildAssetUrlFromResourcesRoot(getActivity(), url)); } Intent intent = new Intent(getActivity(), TitaniumVideoActivity.class); intent.setData(uri); TitaniumIntentWrapper videoIntent = new TitaniumIntentWrapper(intent); videoIntent.setWindowId(TitaniumIntentWrapper.createActivityName("VIDEO")); result = new TitaniumVideo(this, videoIntent); } catch (JSONException e2) { String msg = "contentURL is required."; Log.e(LCAT, msg); if (errorCallback != null) { invokeUserCallback(errorCallback, createJSONError(0, msg)); } } } catch (JSONException e) { Log.e(LCAT, "Could not reconstruct options from JSON: ", e); } return result; }
public String appURLToPath(String url) { return TitaniumUrlHelper.joinUrls("file:///android_asset", url); }