mirror of
https://github.com/sifacaii/VlcJellyfin
synced 2025-06-03 00:58:06 -04:00
添加search
This commit is contained in:
parent
02ea0ee07a
commit
8cc08ebe2e
@ -266,24 +266,7 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
});
|
||||
}
|
||||
|
||||
public Video getMedia(JsonObject item) {
|
||||
//String playUrl = Utils.JellyfinUrl + "/videos/" + id + "/stream.mp4?static=true&a";
|
||||
Video media = new Video();
|
||||
media.Id = Utils.getJsonString(item, "Id").getAsString();
|
||||
media.Name = Utils.getJsonString(item, "Name").getAsString();
|
||||
JsonObject ImageTags = item.get("ImageTags").getAsJsonObject();
|
||||
if (ImageTags.has("Primary")) {
|
||||
String imgid = ImageTags.get("Primary").getAsString();
|
||||
media.cover = Utils.getImgUrl(media.Id, imgid);
|
||||
}
|
||||
media.Url = Utils.config.getJellyfinUrl() + "/videos/" + media.Id + "/stream.mp4?static=true&a";
|
||||
if (item.has("UserData")) {
|
||||
JsonObject userdata = item.get("UserData").getAsJsonObject();
|
||||
media.startPositionTicks = userdata.get("PlaybackPositionTicks").getAsLong();
|
||||
}
|
||||
|
||||
return media;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
@ -317,6 +300,30 @@ public class DetailActivity extends BaseActivity implements JAdapter.OnItemClick
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 组合播放媒体
|
||||
* @param item
|
||||
* @return
|
||||
*/
|
||||
public Video getMedia(JsonObject item) {
|
||||
//String playUrl = Utils.JellyfinUrl + "/videos/" + id + "/stream.mp4?static=true&a";
|
||||
Video media = new Video();
|
||||
media.Id = Utils.getJsonString(item, "Id").getAsString();
|
||||
media.Name = Utils.getJsonString(item, "Name").getAsString();
|
||||
JsonObject ImageTags = item.get("ImageTags").getAsJsonObject();
|
||||
if (ImageTags.has("Primary")) {
|
||||
String imgid = ImageTags.get("Primary").getAsString();
|
||||
media.cover = Utils.getImgUrl(media.Id, imgid);
|
||||
}
|
||||
media.Url = Utils.config.getJellyfinUrl() + "/videos/" + media.Id + "/stream.mp4?static=true&a";
|
||||
if (item.has("UserData")) {
|
||||
JsonObject userdata = item.get("UserData").getAsJsonObject();
|
||||
media.startPositionTicks = userdata.get("PlaybackPositionTicks").getAsLong();
|
||||
}
|
||||
|
||||
return media;
|
||||
}
|
||||
|
||||
public void toVlcPlayer() {
|
||||
Intent intent = new Intent(this, VlcPlayerActivity.class);
|
||||
this.startActivity(intent);
|
||||
|
@ -107,7 +107,6 @@ public class MainActivity extends BaseActivity {
|
||||
* 添加类别行
|
||||
*/
|
||||
private void addRowTvRecyclerView(String title, JsonArray data, boolean horizon) {
|
||||
Log.d(TAG, "addRowTvRecyclerView: " + data.toString());
|
||||
JRecyclerView tvRecyclerView = (JRecyclerView) LayoutInflater.from(this)
|
||||
.inflate(R.layout.home_horizon_tvrecycler, null);
|
||||
((V7LinearLayoutManager) tvRecyclerView.getLayoutManager()).setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.sifacai.vlcjellyfin;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.telecom.Call;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
@ -13,8 +16,8 @@ import com.google.gson.JsonObject;
|
||||
import com.owen.tvrecyclerview.widget.TvRecyclerView;
|
||||
import com.owen.tvrecyclerview.widget.V7GridLayoutManager;
|
||||
|
||||
public class SearchActivity extends BaseActivity{
|
||||
private TvRecyclerView mGridContiner;
|
||||
public class SearchActivity extends BaseActivity implements JAdapter.OnItemClickListener {
|
||||
private TvRecyclerView mGridView;
|
||||
private JAdapter adapter;
|
||||
private final int limit = 24;
|
||||
private String BaseUrl;
|
||||
@ -33,26 +36,27 @@ public class SearchActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
ActionBar actionBar = getSupportActionBar();
|
||||
if(null != actionBar){
|
||||
if (null != actionBar) {
|
||||
ImageView acb = actionBar.getCustomView().findViewById(R.id.activeBar_searchBtn);
|
||||
if(null != acb){
|
||||
if (null != acb) {
|
||||
acb.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
mGridContiner = findViewById(R.id.mGridView);
|
||||
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this,6);
|
||||
mGridContiner.setLayoutManager(v7GridLayoutManager);
|
||||
mGridContiner.setItemAnimator(null); //防崩溃
|
||||
mGridView = findViewById(R.id.mGridView);
|
||||
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this, 6);
|
||||
mGridView.setLayoutManager(v7GridLayoutManager);
|
||||
mGridView.setItemAnimator(null); //防崩溃
|
||||
|
||||
adapter = new JAdapter(new JsonArray());
|
||||
mGridContiner.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(this);
|
||||
mGridView.setAdapter(adapter);
|
||||
|
||||
BaseUrl = "/Users/"+Utils.UserId+"/Items?";
|
||||
BaseUrl = "/Users/" + Utils.UserId + "/Items?";
|
||||
BaseUrl += "Fields=PrimaryImageAspectRatio,CanDelete,BasicSyncInfo,MediaSourceCount";
|
||||
BaseUrl += "&Recursive=true&EnableTotalRecordCount=false&ImageTypeLimit=1&IncludePeople=false";
|
||||
BaseUrl += "&IncludeMedia=true&IncludeGenres=false&IncludeStudios=false&IncludeArtists=false";
|
||||
BaseUrl += "&Limit="+limit;
|
||||
BaseUrl += "&Limit=" + limit;
|
||||
|
||||
searchTermEdit = findViewById(R.id.searchTermEdit);
|
||||
searchBtn = findViewById(R.id.searchBtn);
|
||||
@ -60,7 +64,8 @@ public class SearchActivity extends BaseActivity{
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String st = searchTermEdit.getText().toString().trim();
|
||||
if(st.length()>0){
|
||||
if (st.length() > 0) {
|
||||
adapter.clearItems();
|
||||
Search(st);
|
||||
}
|
||||
}
|
||||
@ -70,9 +75,9 @@ public class SearchActivity extends BaseActivity{
|
||||
}
|
||||
|
||||
private void Search(String searchTerm) {
|
||||
String movieUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Movie";
|
||||
String seriesUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Series";
|
||||
String episodeUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Episode";
|
||||
String movieUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Movie";
|
||||
String seriesUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Series";
|
||||
String episodeUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Episode";
|
||||
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
@ -80,8 +85,8 @@ public class SearchActivity extends BaseActivity{
|
||||
showLoadingDialog("搜索中………………");
|
||||
String movieStr = Utils.okhttpSend(movieUrl);
|
||||
String seriesStr = Utils.okhttpSend(seriesUrl);
|
||||
JsonObject moviejob = Utils.JsonToObj(movieStr,JsonObject.class);
|
||||
JsonObject seriesjob = Utils.JsonToObj(seriesStr,JsonObject.class);
|
||||
JsonObject moviejob = Utils.JsonToObj(movieStr, JsonObject.class);
|
||||
JsonObject seriesjob = Utils.JsonToObj(seriesStr, JsonObject.class);
|
||||
JsonArray movieItems = moviejob.get("Items").getAsJsonArray();
|
||||
JsonArray seriesItems = seriesjob.get("Items").getAsJsonArray();
|
||||
movieItems.addAll(seriesItems);
|
||||
@ -91,13 +96,32 @@ public class SearchActivity extends BaseActivity{
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void fillItems(JsonArray items){
|
||||
private void fillItems(JsonArray items) {
|
||||
mAA.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.clearItems();
|
||||
adapter.addItems(items);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(JsonObject jo) {
|
||||
String itemId = jo.get("Id").getAsString();
|
||||
String type = jo.get("Type").getAsString();
|
||||
Intent intent = null;
|
||||
switch (type) {
|
||||
case "Series":
|
||||
case "Season":
|
||||
case "Episode":
|
||||
case "Movie":
|
||||
case "Video":
|
||||
intent = new Intent(this, DetailActivity.class);
|
||||
intent.putExtra("itemId", itemId);
|
||||
this.startActivity(intent);
|
||||
break;
|
||||
default:
|
||||
ShowToask("未知媒体类型!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,20 +5,15 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.videolan.libvlc.LibVLC;
|
||||
import org.videolan.libvlc.Media;
|
||||
import org.videolan.libvlc.MediaPlayer;
|
||||
import org.videolan.libvlc.interfaces.IMedia;
|
||||
import org.videolan.libvlc.util.VLCVideoLayout;
|
||||
|
||||
import java.util.Timer;
|
||||
@ -275,7 +270,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
||||
public void onClick(View view) {
|
||||
playListMenu.dismiss();
|
||||
if (m.id != Utils.playIndex) {
|
||||
ReportPlayState(Utils.ReportType.stop,Utils.playList.get(Utils.playIndex).Id);
|
||||
ReportPlayState(Utils.ReportType.stop, Utils.playList.get(Utils.playIndex).Id);
|
||||
Utils.playIndex = m.id;
|
||||
play();
|
||||
}
|
||||
@ -412,7 +407,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
||||
* 播放下一集
|
||||
*/
|
||||
public void playNext() {
|
||||
if(Utils.playIndex < (Utils.playList.size() - 1)){
|
||||
if (Utils.playIndex < (Utils.playList.size() - 1)) {
|
||||
ReportPlayState(Utils.ReportType.stop, Utils.playList.get(Utils.playIndex).Id);
|
||||
Utils.playIndex += 1;
|
||||
play();
|
||||
@ -439,7 +434,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
||||
progressTime.cancel();
|
||||
progressTime = null;
|
||||
}
|
||||
if (reportProcessTime != null){
|
||||
if (reportProcessTime != null) {
|
||||
reportProcessTime.cancel();
|
||||
progressTime = null;
|
||||
}
|
||||
|
@ -6,37 +6,32 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="1200dp"
|
||||
android:layout_height="32dp"
|
||||
android:padding="@dimen/padding_border"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="60dp"
|
||||
android:gravity="center"
|
||||
android:paddingLeft="60dp"
|
||||
android:paddingRight="60dp"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TTTTT" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchTermEdit"
|
||||
android:layout_width="600dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:maxLength="20"
|
||||
android:maxLines="1"
|
||||
android:focusable="true"
|
||||
android:tooltipText="关键字"/>
|
||||
android:tooltipText="关键字" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/searchBtn"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="@dimen/button_margin_left"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_outline_search_48"
|
||||
android:background="@drawable/shape_user_focus"
|
||||
android:layout_marginLeft="@dimen/button_margin_left" />
|
||||
android:src="@drawable/ic_outline_search_48" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="TTTTT" />
|
||||
</LinearLayout>
|
||||
|
||||
<org.sifacai.vlcjellyfin.JRecyclerView
|
||||
@ -49,4 +44,5 @@
|
||||
app:tv_horizontalSpacingWithMargins="@dimen/vh_space_width"
|
||||
app:tv_selectedItemIsCentered="true"
|
||||
app:tv_verticalSpacingWithMargins="@dimen/vh_space_width" />
|
||||
|
||||
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user