forked from jianjunxiao/NiceVieoPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
51 changed files
with
1,603 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
app/src/main/java/com/xiao/nicevieoplayer/example/ChangeClarityActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.xiao.nicevieoplayer.example; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.bumptech.glide.Glide; | ||
import com.xiao.nicevideoplayer.Clarity; | ||
import com.xiao.nicevideoplayer.NiceVideoPlayer; | ||
import com.xiao.nicevideoplayer.NiceVideoPlayerManager; | ||
import com.xiao.nicevideoplayer.TxVideoPlayerController; | ||
import com.xiao.nicevieoplayer.R; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class ChangeClarityActivity extends AppCompatActivity { | ||
|
||
private NiceVideoPlayer mNiceVideoPlayer; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_change_clarity); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
mNiceVideoPlayer = (NiceVideoPlayer) findViewById(R.id.nice_video_player); | ||
mNiceVideoPlayer.setPlayerType(NiceVideoPlayer.TYPE_IJK); // IjkPlayer or MediaPlayer | ||
TxVideoPlayerController controller = new TxVideoPlayerController(this); | ||
controller.setTitle("Beautiful China..."); | ||
controller.setLenght(117000); | ||
controller.setClarity(getClarites(), 0); | ||
Glide.with(this) | ||
.load("http://imgsrc.baidu.com/image/c0%3Dshijue%2C0%2C0%2C245%2C40/sign=304dee3ab299a9012f38537575fc600e/91529822720e0cf3f8b77cd50046f21fbe09aa5f.jpg") | ||
.placeholder(R.drawable.img_default) | ||
.crossFade() | ||
.into(controller.imageView()); | ||
mNiceVideoPlayer.setController(controller); | ||
} | ||
|
||
public List<Clarity> getClarites() { | ||
List<Clarity> clarities = new ArrayList<>(); | ||
clarities.add(new Clarity("标清", "270P", "http://play.g3proxy.lecloud.com/vod/v2/MjUxLzE2LzgvbGV0di11dHMvMTQvdmVyXzAwXzIyLTExMDc2NDEzODctYXZjLTE5OTgxOS1hYWMtNDgwMDAtNTI2MTEwLTE3MDg3NjEzLWY1OGY2YzM1NjkwZTA2ZGFmYjg2MTVlYzc5MjEyZjU4LTE0OTg1NTc2ODY4MjMubXA0?b=259&mmsid=65565355&tm=1499247143&key=f0eadb4f30c404d49ff8ebad673d3742&platid=3&splatid=345&playid=0&tss=no&vtype=21&cvid=2026135183914&payff=0&pip=08cc52f8b09acd3eff8bf31688ddeced&format=0&sign=mb&dname=mobile&expect=1&tag=mobile&xformat=super")); | ||
clarities.add(new Clarity("高清", "480P", "http://play.g3proxy.lecloud.com/vod/v2/MjQ5LzM3LzIwL2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMTA3NjQxMzkwLWF2Yy00MTk4MTAtYWFjLTQ4MDAwLTUyNjExMC0zMTU1NTY1Mi00ZmJjYzFkNzA1NWMyNDc4MDc5OTYxODg1N2RjNzEwMi0xNDk4NTU3OTYxNzQ4Lm1wNA==?b=479&mmsid=65565355&tm=1499247143&key=98c7e781f1145aba07cb0d6ec06f6c12&platid=3&splatid=345&playid=0&tss=no&vtype=13&cvid=2026135183914&payff=0&pip=08cc52f8b09acd3eff8bf31688ddeced&format=0&sign=mb&dname=mobile&expect=1&tag=mobile&xformat=super")); | ||
clarities.add(new Clarity("超清", "720P", "http://play.g3proxy.lecloud.com/vod/v2/MjQ5LzM3LzIwL2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMTA3NjQxMzkwLWF2Yy00MTk4MTAtYWFjLTQ4MDAwLTUyNjExMC0zMTU1NTY1Mi00ZmJjYzFkNzA1NWMyNDc4MDc5OTYxODg1N2RjNzEwMi0xNDk4NTU3OTYxNzQ4Lm1wNA==?b=479&mmsid=65565355&tm=1499247143&key=98c7e781f1145aba07cb0d6ec06f6c12&platid=3&splatid=345&playid=0&tss=no&vtype=13&cvid=2026135183914&payff=0&pip=08cc52f8b09acd3eff8bf31688ddeced&format=0&sign=mb&dname=mobile&expect=1&tag=mobile&xformat=super")); | ||
clarities.add(new Clarity("蓝光", "1080P", "http://play.g3proxy.lecloud.com/vod/v2/MjQ5LzM3LzIwL2xldHYtdXRzLzE0L3Zlcl8wMF8yMi0xMTA3NjQxMzkwLWF2Yy00MTk4MTAtYWFjLTQ4MDAwLTUyNjExMC0zMTU1NTY1Mi00ZmJjYzFkNzA1NWMyNDc4MDc5OTYxODg1N2RjNzEwMi0xNDk4NTU3OTYxNzQ4Lm1wNA==?b=479&mmsid=65565355&tm=1499247143&key=98c7e781f1145aba07cb0d6ec06f6c12&platid=3&splatid=345&playid=0&tss=no&vtype=13&cvid=2026135183914&payff=0&pip=08cc52f8b09acd3eff8bf31688ddeced&format=0&sign=mb&dname=mobile&expect=1&tag=mobile&xformat=super")); | ||
return clarities; | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
NiceVideoPlayerManager.instance().releaseNiceVideoPlayer(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
if (NiceVideoPlayerManager.instance().onBackPressd()) return; | ||
super.onBackPressed(); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
app/src/main/java/com/xiao/nicevieoplayer/example/DemoFragenment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.xiao.nicevieoplayer.example; | ||
|
||
import android.os.Bundle; | ||
import android.support.annotation.Nullable; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import com.xiao.nicevideoplayer.NiceVideoPlayer; | ||
import com.xiao.nicevideoplayer.NiceVideoPlayerManager; | ||
import com.xiao.nicevieoplayer.R; | ||
import com.xiao.nicevieoplayer.example.adapter.VideoAdapter; | ||
import com.xiao.nicevieoplayer.example.util.DataUtil; | ||
|
||
/** | ||
* Created by XiaoJianjun on 2017/7/7. | ||
* 如果你需要在播放的时候按下Home键能暂停,回调此Fragment又继续的话,需要继承自CompatHomeKeyFragment | ||
*/ | ||
public class DemoFragenment extends Fragment { | ||
|
||
private RecyclerView mRecyclerView; | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.layout_fragment_demo, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
mRecyclerView = (RecyclerView) getView().findViewById(R.id.recycler_view); | ||
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); | ||
mRecyclerView.setHasFixedSize(true); | ||
VideoAdapter adapter = new VideoAdapter(getActivity(), DataUtil.getVideoListData()); | ||
mRecyclerView.setAdapter(adapter); | ||
mRecyclerView.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() { | ||
@Override | ||
public void onChildViewAttachedToWindow(View view) { | ||
|
||
} | ||
|
||
@Override | ||
public void onChildViewDetachedFromWindow(View view) { | ||
NiceVideoPlayer niceVideoPlayer = (NiceVideoPlayer) view.findViewById(R.id.nice_video_player); | ||
if (niceVideoPlayer == NiceVideoPlayerManager.instance().getCurrentNiceVideoPlayer()) { | ||
NiceVideoPlayerManager.instance().releaseNiceVideoPlayer(); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onStop() { | ||
super.onStop(); | ||
NiceVideoPlayerManager.instance().releaseNiceVideoPlayer(); | ||
} | ||
} |
Oops, something went wrong.