本文介绍了用于 Android 应用程序的 UPnP 搜索和搜索栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我一直在尝试使用我的 UPnP Android 应用程序实现 Seek(),但没有成功.

I have been trying to implement Seek() with my UPnP Android App but have not had success.

我有我的搜索栏和侦听器,但是当我将搜索栏拖动到新位置时它总是失败.

I have my seekbar and listener but it it keeps failing when I drag the seekbar to a new position.

seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener()
{
    @Override
    public void onProgressChanged(SeekBar arg0, int arg1, boolean arg2)
    {
        Log.i("SEEKTIME", "time:" + arg1);
        upnpService.getControlPoint().execute(new Seek(service, SeekMode.REL_TIME,   arg0.toString())
        {
            @Override
            public void success(ActionInvocation invocation)
            {
                //super.success(invocation);
                Log.i("SEEKSUCCESS", "success seek");
            }
            @Override
            public void failure(ActionInvocation arg0, UpnpResponse arg1, String arg2)
            {
                Log.i("SEEKFAIL", "fail seek");
            }
        });
    }

当我拖动到搜索栏上的新位置时,它会触发失败方法.

When I drag to a new position on the seekbar it triggers the failure method.

有什么想法吗???

我使用 BubbleUPnP 作为渲染器.下面列出了设备 XML.

I am using BubbleUPnP as the renderer. The device XML is listed below.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
    <major>1</major>
    <minor>0</minor>
</specVersion>
<device>
    <deviceType>urn:schemas-upnp-org:device:MediaRenderer:1</deviceType>
    <UDN>uuid:2797d98f-173f-fe46-0000-00002d731080</UDN>
    <friendlyName>BubbleUPnP (Nexus One)</friendlyName>
    <manufacturer>Bubblesoft</manufacturer>
    <manufacturerURL>http://forum.xda-developers.com/showthread.php?t=1118891
    </manufacturerURL>
    <modelDescription>BubbleUPnP Media Renderer</modelDescription>
    <modelName>BubbleUPnP Media Renderer</modelName>
    <modelNumber>1.4.3.1</modelNumber>
    <modelURL />
    <iconList>
        <icon>
            <mimetype>image/png</mimetype>
            <width>72</width>
            <height>72</height>
            <depth>32</depth>
            <url>/dev/2797d98f-173f-fe46-0000-00002d731080/icon.png</url>
        </icon>
    </iconList>
    <serviceList>
        <service>
            <serviceType>urn:schemas-upnp-org:service:AVTransport:1
            </serviceType>
            <serviceId>urn:upnp-org:serviceId:AVTransport</serviceId>
            <controlURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/AVTransport/action
            </controlURL>
            <eventSubURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/AVTransport/event
            </eventSubURL>
            <SCPDURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/AVTransport/desc.xml
            </SCPDURL>
        </service>
        <service>
            <serviceType>urn:schemas-upnp-org:service:RenderingControl:1
            </serviceType>
            <serviceId>urn:upnp-org:serviceId:RenderingControl</serviceId>
            <controlURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/RenderingControl/action
            </controlURL>
            <eventSubURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/RenderingControl/event
            </eventSubURL>
            <SCPDURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/RenderingControl/desc.xml
            </SCPDURL>
        </service>
        <service>
            <serviceType>urn:schemas-upnp-org:service:ConnectionManager:1
            </serviceType>
            <serviceId>urn:upnp-org:serviceId:ConnectionManager</serviceId>
            <controlURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/ConnectionManager/action
            </controlURL>
            <eventSubURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/ConnectionManager/event
            </eventSubURL>
            <SCPDURL>/dev/2797d98f-173f-fe46-0000-00002d731080/svc/upnp-org/ConnectionManager/desc.xml
            </SCPDURL>
        </service>
    </serviceList>
</device>

推荐答案

我知道答案已经很久了,但我是通过与 DLNA 和 UPNP 合作来解决这个问题的.我决定回答这个问题,以便它对其他 STACKERS (:P) 有用.如果您可以使用 DLNA,这里 是您可以用来实现您的要求的代码.它还支持UPNP.

I know it has been a long time to answer, but I came to this question by working with DLNA and UPNP. I decided to answer this question so that it can be useful to other STACKERS (:P). If you can use DLNA, here is the code you can use to achieve your requirement. It also supports UPNP.

它使用搜索栏来显示当前正在运行的媒体的进度.希望您能找到您的需求.

It is using seekbar to show progress of currently running media. Hope you will find your requirement.

基本上,您需要使用来自 upnp 服务的 getPositionInfo() 回调.您可以在每个特定的持续时间(例如 500 毫秒)请求此回调.这是回调:

Basically, You need to use getPositionInfo() callback from upnp service. You can request this callback every specific time duration, lets say 500 millis. Here is callback:

   try {
        Service localService = this.executeDeviceItem.getDevice()
                .findService(new UDAServiceType("AVTransport"));
        if (localService != null) {
            this.upnpService.getControlPoint().execute(
                    new GetPositionInfoCallback(localService, mHandle,
                            this.activity));
        } else {
        }
    } catch (Exception localException) {
        localException.printStackTrace();
    }

您可以根据回调返回的数据更新您的搜索栏.像这样:

You can update your seekbar as per data returned from callback. Something like this:

Bundle localBundle = paramIntent.getExtras();
String str1 = localBundle.getString("TrackDuration");
String str2 = localBundle.getString("RelTime");
int i = com.techd.tvapp.util.Utils.getRealTime(str1);
int j = Utils.getRealTime(str2);
mSeekBar.setMax(i);
mSeekBar.setProgress(j);
mTotalTime.setText(str1);
mCurrentTime.setText(str2);

要使用seekbar更新您的播放器,请将seekbarchange监听器设置为:

To update your player using seekbar, set seekbarchange listener to this:

class PlaySeekBarListener implements SeekBar.OnSeekBarChangeListener {
        PlaySeekBarListener() {
        }

        public void onProgressChanged(SeekBar paramSeekBar, int paramInt,
                                      boolean paramBoolean) {
        }

        public void onStartTrackingTouch(SeekBar paramSeekBar) {
            // isUpdatePlaySeek = false;
        }

        public void onStopTrackingTouch(SeekBar paramSeekBar) {
            if (null != dmcControl) {
                String str = com.techd.tvapp.util.Utils.secToTime(paramSeekBar.getProgress());
                Log.i("DMC", "SeekBar time:" + str);
                dmcControl.seekBarPosition(str);
            }
        }
    }

mSeekBar = (SeekBar) findViewById(R.id.media_seekBar);
mSeekBar.setOnSeekBarChangeListener(new PlaySeekBarListener());

就是这样!

这篇关于用于 Android 应用程序的 UPnP 搜索和搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 19:58