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
|
@Override
|
||||||
public void onClick(JsonObject jo) {
|
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() {
|
public void toVlcPlayer() {
|
||||||
Intent intent = new Intent(this, VlcPlayerActivity.class);
|
Intent intent = new Intent(this, VlcPlayerActivity.class);
|
||||||
this.startActivity(intent);
|
this.startActivity(intent);
|
||||||
|
@ -107,7 +107,6 @@ public class MainActivity extends BaseActivity {
|
|||||||
* 添加类别行
|
* 添加类别行
|
||||||
*/
|
*/
|
||||||
private void addRowTvRecyclerView(String title, JsonArray data, boolean horizon) {
|
private void addRowTvRecyclerView(String title, JsonArray data, boolean horizon) {
|
||||||
Log.d(TAG, "addRowTvRecyclerView: " + data.toString());
|
|
||||||
JRecyclerView tvRecyclerView = (JRecyclerView) LayoutInflater.from(this)
|
JRecyclerView tvRecyclerView = (JRecyclerView) LayoutInflater.from(this)
|
||||||
.inflate(R.layout.home_horizon_tvrecycler, null);
|
.inflate(R.layout.home_horizon_tvrecycler, null);
|
||||||
((V7LinearLayoutManager) tvRecyclerView.getLayoutManager()).setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
((V7LinearLayoutManager) tvRecyclerView.getLayoutManager()).setOrientation(V7LinearLayoutManager.HORIZONTAL);
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package org.sifacai.vlcjellyfin;
|
package org.sifacai.vlcjellyfin;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.telecom.Call;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -13,8 +16,8 @@ import com.google.gson.JsonObject;
|
|||||||
import com.owen.tvrecyclerview.widget.TvRecyclerView;
|
import com.owen.tvrecyclerview.widget.TvRecyclerView;
|
||||||
import com.owen.tvrecyclerview.widget.V7GridLayoutManager;
|
import com.owen.tvrecyclerview.widget.V7GridLayoutManager;
|
||||||
|
|
||||||
public class SearchActivity extends BaseActivity{
|
public class SearchActivity extends BaseActivity implements JAdapter.OnItemClickListener {
|
||||||
private TvRecyclerView mGridContiner;
|
private TvRecyclerView mGridView;
|
||||||
private JAdapter adapter;
|
private JAdapter adapter;
|
||||||
private final int limit = 24;
|
private final int limit = 24;
|
||||||
private String BaseUrl;
|
private String BaseUrl;
|
||||||
@ -33,26 +36,27 @@ public class SearchActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if(null != actionBar){
|
if (null != actionBar) {
|
||||||
ImageView acb = actionBar.getCustomView().findViewById(R.id.activeBar_searchBtn);
|
ImageView acb = actionBar.getCustomView().findViewById(R.id.activeBar_searchBtn);
|
||||||
if(null != acb){
|
if (null != acb) {
|
||||||
acb.setVisibility(View.GONE);
|
acb.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mGridContiner = findViewById(R.id.mGridView);
|
mGridView = findViewById(R.id.mGridView);
|
||||||
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this,6);
|
V7GridLayoutManager v7GridLayoutManager = new V7GridLayoutManager(this, 6);
|
||||||
mGridContiner.setLayoutManager(v7GridLayoutManager);
|
mGridView.setLayoutManager(v7GridLayoutManager);
|
||||||
mGridContiner.setItemAnimator(null); //防崩溃
|
mGridView.setItemAnimator(null); //防崩溃
|
||||||
|
|
||||||
adapter = new JAdapter(new JsonArray());
|
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 += "Fields=PrimaryImageAspectRatio,CanDelete,BasicSyncInfo,MediaSourceCount";
|
||||||
BaseUrl += "&Recursive=true&EnableTotalRecordCount=false&ImageTypeLimit=1&IncludePeople=false";
|
BaseUrl += "&Recursive=true&EnableTotalRecordCount=false&ImageTypeLimit=1&IncludePeople=false";
|
||||||
BaseUrl += "&IncludeMedia=true&IncludeGenres=false&IncludeStudios=false&IncludeArtists=false";
|
BaseUrl += "&IncludeMedia=true&IncludeGenres=false&IncludeStudios=false&IncludeArtists=false";
|
||||||
BaseUrl += "&Limit="+limit;
|
BaseUrl += "&Limit=" + limit;
|
||||||
|
|
||||||
searchTermEdit = findViewById(R.id.searchTermEdit);
|
searchTermEdit = findViewById(R.id.searchTermEdit);
|
||||||
searchBtn = findViewById(R.id.searchBtn);
|
searchBtn = findViewById(R.id.searchBtn);
|
||||||
@ -60,7 +64,8 @@ public class SearchActivity extends BaseActivity{
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
String st = searchTermEdit.getText().toString().trim();
|
String st = searchTermEdit.getText().toString().trim();
|
||||||
if(st.length()>0){
|
if (st.length() > 0) {
|
||||||
|
adapter.clearItems();
|
||||||
Search(st);
|
Search(st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,9 +75,9 @@ public class SearchActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Search(String searchTerm) {
|
private void Search(String searchTerm) {
|
||||||
String movieUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Movie";
|
String movieUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Movie";
|
||||||
String seriesUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Series";
|
String seriesUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Series";
|
||||||
String episodeUrl = BaseUrl + "&searchTerm="+searchTerm+"&IncludeItemTypes=Episode";
|
String episodeUrl = BaseUrl + "&searchTerm=" + searchTerm + "&IncludeItemTypes=Episode";
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -80,8 +85,8 @@ public class SearchActivity extends BaseActivity{
|
|||||||
showLoadingDialog("搜索中………………");
|
showLoadingDialog("搜索中………………");
|
||||||
String movieStr = Utils.okhttpSend(movieUrl);
|
String movieStr = Utils.okhttpSend(movieUrl);
|
||||||
String seriesStr = Utils.okhttpSend(seriesUrl);
|
String seriesStr = Utils.okhttpSend(seriesUrl);
|
||||||
JsonObject moviejob = Utils.JsonToObj(movieStr,JsonObject.class);
|
JsonObject moviejob = Utils.JsonToObj(movieStr, JsonObject.class);
|
||||||
JsonObject seriesjob = Utils.JsonToObj(seriesStr,JsonObject.class);
|
JsonObject seriesjob = Utils.JsonToObj(seriesStr, JsonObject.class);
|
||||||
JsonArray movieItems = moviejob.get("Items").getAsJsonArray();
|
JsonArray movieItems = moviejob.get("Items").getAsJsonArray();
|
||||||
JsonArray seriesItems = seriesjob.get("Items").getAsJsonArray();
|
JsonArray seriesItems = seriesjob.get("Items").getAsJsonArray();
|
||||||
movieItems.addAll(seriesItems);
|
movieItems.addAll(seriesItems);
|
||||||
@ -91,13 +96,32 @@ public class SearchActivity extends BaseActivity{
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillItems(JsonArray items){
|
private void fillItems(JsonArray items) {
|
||||||
mAA.runOnUiThread(new Runnable() {
|
mAA.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
adapter.clearItems();
|
|
||||||
adapter.addItems(items);
|
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.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.PopupMenu;
|
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.videolan.libvlc.LibVLC;
|
import org.videolan.libvlc.LibVLC;
|
||||||
import org.videolan.libvlc.Media;
|
|
||||||
import org.videolan.libvlc.MediaPlayer;
|
import org.videolan.libvlc.MediaPlayer;
|
||||||
import org.videolan.libvlc.interfaces.IMedia;
|
|
||||||
import org.videolan.libvlc.util.VLCVideoLayout;
|
import org.videolan.libvlc.util.VLCVideoLayout;
|
||||||
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
@ -275,7 +270,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
playListMenu.dismiss();
|
playListMenu.dismiss();
|
||||||
if (m.id != Utils.playIndex) {
|
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;
|
Utils.playIndex = m.id;
|
||||||
play();
|
play();
|
||||||
}
|
}
|
||||||
@ -412,7 +407,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
|||||||
* 播放下一集
|
* 播放下一集
|
||||||
*/
|
*/
|
||||||
public void playNext() {
|
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);
|
ReportPlayState(Utils.ReportType.stop, Utils.playList.get(Utils.playIndex).Id);
|
||||||
Utils.playIndex += 1;
|
Utils.playIndex += 1;
|
||||||
play();
|
play();
|
||||||
@ -439,7 +434,7 @@ public class VlcPlayerActivity extends BaseActivity implements MediaPlayer.Event
|
|||||||
progressTime.cancel();
|
progressTime.cancel();
|
||||||
progressTime = null;
|
progressTime = null;
|
||||||
}
|
}
|
||||||
if (reportProcessTime != null){
|
if (reportProcessTime != null) {
|
||||||
reportProcessTime.cancel();
|
reportProcessTime.cancel();
|
||||||
progressTime = null;
|
progressTime = null;
|
||||||
}
|
}
|
||||||
|
@ -6,37 +6,32 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="1200dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="32dp"
|
android:layout_height="60dp"
|
||||||
android:padding="@dimen/padding_border"
|
android:gravity="center"
|
||||||
|
android:paddingLeft="60dp"
|
||||||
|
android:paddingRight="60dp"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="TTTTT" />
|
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/searchTermEdit"
|
android:id="@+id/searchTermEdit"
|
||||||
android:layout_width="600dp"
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/shape_user_focus"
|
android:maxLength="20"
|
||||||
|
android:maxLines="1"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:tooltipText="关键字"/>
|
android:tooltipText="关键字" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/searchBtn"
|
android:id="@+id/searchBtn"
|
||||||
android:layout_width="100dp"
|
android:layout_width="100dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="40dp"
|
||||||
|
android:layout_marginLeft="@dimen/button_margin_left"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
android:src="@drawable/ic_outline_search_48"
|
|
||||||
android:background="@drawable/shape_user_focus"
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<org.sifacai.vlcjellyfin.JRecyclerView
|
<org.sifacai.vlcjellyfin.JRecyclerView
|
||||||
@ -49,4 +44,5 @@
|
|||||||
app:tv_horizontalSpacingWithMargins="@dimen/vh_space_width"
|
app:tv_horizontalSpacingWithMargins="@dimen/vh_space_width"
|
||||||
app:tv_selectedItemIsCentered="true"
|
app:tv_selectedItemIsCentered="true"
|
||||||
app:tv_verticalSpacingWithMargins="@dimen/vh_space_width" />
|
app:tv_verticalSpacingWithMargins="@dimen/vh_space_width" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
x
Reference in New Issue
Block a user