我正在使用 Firebase 作為資料庫,用戶可以在其中上傳影像或視頻,因此我從我的資料庫中獲取 URL,因此我獲得了兩個 URL,其中一個可以是視頻或影像,因此我可以做些什么來檢測 URL。
假設這是 URL。 這是示例 URL。注意 URL 可以不同
任何幫助將不勝感激
已編輯
為了更好地理解,我將提供一些示例代碼:
MyUserModel model; //this is the model class where I can get the url in String
String Url = model.getUrl(); //its URL can be video or image
//Can I write something like this:
//does any method like this : isVideo();
// if the url is video then this function will return true else false;
if(isVideo(Url)){
videoView.setVideoPath(Url); //and other stuffs
}else{
Glide.with(context).load(Url).into(ImagView); //something like this.
}
...
注意:某些 URL 沒有像
PNG、MP4、JPG等擴展名。我這么說是因為我有一些沒有與 mp4 或 png 等相關的擴展名的 URL。
uj5u.com熱心網友回復:
當您將影像/視頻保存到資料庫中時,我建議您將一列命名為“型別”,并為影像保留 0,為視頻保留 1。這樣您就可以輕松識別型別。
您可能需要稍微調整 UI。您可以提供從 UI 捕獲影像的選項,并僅啟動相機應用程式來捕獲影像。同樣提供僅捕獲視頻的選項。通過這種方式,您可以確保前端用戶一次捕獲影像或視頻。如上所述在 firebase db 中保存該型別值。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/332956.html
上一篇:什么是Ruby中的[]運算子
