gpfduoduo / airplay-receiver-on-android Goto Github PK
View Code? Open in Web Editor NEW在Android中实现Airplay(图片+视频)的接收端
在Android中实现Airplay(图片+视频)的接收端
竟然有类似ihone这样的低级错误...
会给人一种不专业的感觉
建议修改
ImageActivity.java中替换showImage方法:
private void showImage(byte[] data)
{
Bitmap bitmap;
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(data, 0, data.length, opts);
int size = (opts.outWidth * opts.outHeight);
int size_limit = 1920 * 1080 * 4;
if (size > 1920 * 1080 * 4) {
int zoomRate = (int) Math.ceil(size * 1.0 / size_limit);
if (zoomRate <= 0)
zoomRate = 1;
opts.inSampleSize = zoomRate;
}
if (!Thread.currentThread().isInterrupted()) {
opts.inJustDecodeBounds = false;
bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, opts);
iv.setImageBitmap(bitmap);
}
}
原因,由于部分图片过大,导致无法显示,因此应该在生成bitmap时做缩放处理(上述代码的作用是将
bitmap限制在1920*1080以内,毕竟大部分电视只支持1080p,分辨率高于这个意义不大,反而极易导致图片内存溢出等各种问题)
更新代码前,测试切换图片时部分图片不能显示的几率较大,更改后为0
1.目前来看,只有优酷的ios版的airplay设备扫描是自己开发的,其他视频厂商(搜狐,爱奇艺,腾讯,乐视)均采用ios系统提供的设备扫描.因此,优酷总能扫描到本项目创建的airplay设备,但是其他app则存在一定的问题.
2.修改设备名称,并重新发布后,ios系统有时不能更新扫描到的设备名称.
另外,android自4.1起将avahi集成到了其Linux kernel中,并提供了NsdManager service进行设备的发布register和扫描discover. 但是其效果貌似还不如jmdns? 发布的设备很难被ios系统扫描到. 并且部分手机不支持NsdServiceInfo的setAttribute方法(method not found),导致无法设置设备属性如deviceid...
Hello,
I tried to use your sample application to make an airplay receiver on an Android Phone.
But it seems that my iPhone does not detect the Android Phone.
Can you please tell me what's wrong ?
thank you
Hi. Very nice project. Is it GPL 2.0 or Apache 2.0 or MIT or something else? Thanks.
如果从VitamioPlayer更换为系统的MediaPlayer,就会发现各种mediaPlayer的illegalState异常,而代码中异常捕获太少,各种崩溃
如:timerTask启动太早,应该在startVideoPlayback函数中启动.否则各种异常
另外清理工作不够彻底,也容易导致播放器异常
private void doCleanUp() {
mVideoWidth = 0;
mVideoHeight = 0;
mIsVideoReadyToBePlayed = false;
mIsVideoSizeKnown = false;
releaseMediaPlayer();
handler.removeCallbacksAndMessages(null);
if (timerTask != null) {
timerTask.cancel();
timerTask = null;
}
if (timer != null) {
timer.cancel();
timer = null;
}
}
最好还是用系统播放器来做,等ok后,再替换为Vitamio,否则各种问题被隐藏.
好不容易找到你写的这个AirPlay,真是太用心了,我编译居然可以运行起来。正好我上司让我研究这个协议,将IOS投屏到安卓。我测试过你的,投图片可以,视频好像不行。而且这个在8.0 IOS下优酷投视频也好像不行。
不知道你是否已经解决这个问题,如果有解决可不可以提供下解决办法,十万火急就差这一步了。如果能解决,我个人愿意在你的开源http://kymjs.com/ 捐助,以献绵薄之力。我的邮箱:[email protected]
望指教
编译安装到手机后,一点击APP就闪了一下,跑不起来。有下面的打印输出:
V/ActivityThread: Handling launch of ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}}
02-14 10:44:58.957 22673-22673/com.guo.duoduo.airplayreceiver V/ActivityThread: ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}}: app=com.guo.duoduo.airplayreceiver.MyApplication@1685c4b3, appName=com.guo.duoduo.airplayreceiver, pkg=com.guo.duoduo.airplayreceiver, comp={com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}, dir=/data/app/com.guo.duoduo.airplayreceiver-2/base.apk
02-14 10:44:58.975 22673-22673/com.guo.duoduo.airplayreceiver W/ResourceType: No package identifier when getting value for resource number 0x00000000
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver V/ActivityThread: Performing resume of ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}}
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver V/ActivityThread: Resume ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}} started activity: false, hideForNow: false, finished: true
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver D/LEUI_ActivityThread: Add flag(FLAG_SHOW_WHEN_LOCKED)for activity window =com.guo.duoduo.airplayreceiver.ui.MainActivityflags=10200000
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver V/ActivityThread: Scheduling idle handler for ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}}
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{1d4009e8 token=android.os.BinderProxy@8b91801 {com.guo.duoduo.airplayreceiver/com.guo.duoduo.airplayreceiver.ui.MainActivity}}
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver D/ActivityThread: SVC-Calling onStartCommand: com.guo.duoduo.airplayreceiver.service.RegisterService@f677ccd, flags=0, startId=3
02-14 10:44:59.018 22673-22673/com.guo.duoduo.airplayreceiver D/ActivityThread: SVC-SERVICE_ARGS handled : 0 / ServiceArgsData{token=android.os.BinderProxy@24e543ff startId=3 args=Intent { cmp=com.guo.duoduo.airplayreceiver/.service.RegisterService }}
02-14 10:44:59.046 22673-22673/com.guo.duoduo.airplayreceiver D/ActivityThread: ACT-PAUSE_ACTIVITY_FINISHING handled : 0 / android.os.BinderProxy@8b91801
02-14 10:44:59.066 22673-22706/com.guo.duoduo.airplayreceiver D/OpenGLRenderer: Flushing caches (mode 1)
02-14 10:44:59.066 22673-22706/com.guo.duoduo.airplayreceiver D/OpenGLRenderer: PathCache::clear count = 0
02-14 10:44:59.067 22673-22673/com.guo.duoduo.airplayreceiver D/ActivityThread: ACT-DESTROY_ACTIVITY handled : 1 / android.os.BinderProxy@8b91801
02-14 10:45:04.030 22673-22688/com.guo.duoduo.airplayreceiver W/art: Suspending all threads took: 24.526ms
很高兴看到你的开源工程,请问楼主是否要实现Airplay Mirroring功能?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.