當前位置: 首頁>>代碼示例>>Java>>正文


Java WebOSWebAppSession類代碼示例

本文整理匯總了Java中com.connectsdk.service.sessions.WebOSWebAppSession的典型用法代碼示例。如果您正苦於以下問題:Java WebOSWebAppSession類的具體用法?Java WebOSWebAppSession怎麽用?Java WebOSWebAppSession使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WebOSWebAppSession類屬於com.connectsdk.service.sessions包,在下文中一共展示了WebOSWebAppSession類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: closeWebApp

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Override
public void closeWebApp(LaunchSession launchSession, final ResponseListener<Object> listener) {
    if (launchSession == null || launchSession.getAppId() == null || launchSession.getAppId().length() == 0) {
        Util.postError(listener, new ServiceCommandError(0, "Must provide a valid launch session", null));
        return;
    }

    final WebOSWebAppSession webAppSession = mWebAppSessions.get(launchSession.getAppId());
    if (webAppSession != null) {
        webAppSession.disconnectFromWebApp();
    }

    String uri = "ssap://webapp/closeWebApp";
    JSONObject payload = new JSONObject();

    try {
        if (launchSession.getAppId() != null) payload.put("webAppId", launchSession.getAppId());
        if (launchSession.getSessionId() != null) payload.put("sessionId", launchSession.getSessionId());
    } catch (JSONException e) {
        e.printStackTrace();
    }

    ServiceCommand<ResponseListener<Object>> request = new ServiceCommand<ResponseListener<Object>>(this, uri, payload, true, listener);
    request.send();
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:26,代碼來源:WebOSTVService.java

示例2: connectToApp

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
public void connectToApp(String appId, final WebAppSession.LaunchListener listener) {
    LaunchSession launchSession = LaunchSession.launchSessionForAppId(appId);
    launchSession.setSessionType(LaunchSessionType.App);
    launchSession.setService(this);

    final WebOSWebAppSession webAppSession = webAppSessionForLaunchSession(launchSession);

    connectToWebApp(webAppSession, false, new ResponseListener<Object>() {
        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }

        @Override
        public void onSuccess(Object object) {
            Util.postSuccess(listener, webAppSession);
        }
    });
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:20,代碼來源:WebOSTVService.java

示例3: joinWebApp

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Override
public void joinWebApp(final LaunchSession webAppLaunchSession, final WebAppSession.LaunchListener listener) {
    final WebOSWebAppSession webAppSession = this.webAppSessionForLaunchSession(webAppLaunchSession);

    webAppSession.join(new ResponseListener<Object>() {

        @Override
        public void onError(ServiceCommandError error) {
            Util.postError(listener, error);
        }

        @Override
        public void onSuccess(Object object) {
            Util.postSuccess(listener, webAppSession);
        }
    });
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:18,代碼來源:WebOSTVService.java

示例4: testPlayMediaDeprecatedWithAllParametersOnTheLatestWebOS

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Test
public void testPlayMediaDeprecatedWithAllParametersOnTheLatestWebOS() {
    MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
    WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
    service.mWebAppSessions.put("MediaPlayer", webAppSession);

    MediaInfo mediaInfo = new MediaInfo.Builder("url", "mimetype")
            .setTitle("title")
            .setDescription("description")
            .setIcon("icon")
            .build();
    boolean shouldLoop = true;
    service.playMedia(mediaInfo.getUrl(), mediaInfo.getMimeType(), mediaInfo.getTitle(),
            mediaInfo.getDescription(), mediaInfo.getImages().get(0).getUrl(), shouldLoop,
            listener);

    verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:19,代碼來源:WebOSTVServiceTest.java

示例5: verifyPlayMediaOnTheLatestWebOS

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
private void verifyPlayMediaOnTheLatestWebOS(MediaInfo mediaInfo, boolean shouldLoop, MediaPlayer.LaunchListener listener, WebOSWebAppSession webAppSession) {
    // should try to join to the web app
    ArgumentCaptor<ResponseListener> argListener = ArgumentCaptor.forClass(ResponseListener
            .class);
    Mockito.verify(webAppSession).join(argListener.capture());

    // run join success
    ResponseListener webAppListener = argListener.getValue();
    webAppListener.onSuccess(null);
    Robolectric.runUiThreadTasksIncludingDelayedTasks();

    // should delegate playing media to the WebAppSession
    ArgumentCaptor<MediaInfo> argMediaInfo = ArgumentCaptor.forClass(MediaInfo.class);
    ArgumentCaptor<Boolean> argShouldLoop = ArgumentCaptor.forClass(Boolean.class);
    Mockito.verify(webAppSession).playMedia(argMediaInfo.capture(), argShouldLoop.capture(),
            Mockito.same(listener));

    MediaInfo capturedMediaInfo = argMediaInfo.getValue();
    Assert.assertEquals(mediaInfo.getDescription(), capturedMediaInfo.getDescription());
    Assert.assertEquals(mediaInfo.getMimeType(), capturedMediaInfo.getMimeType());
    Assert.assertEquals(mediaInfo.getTitle(), capturedMediaInfo.getTitle());
    Assert.assertEquals(mediaInfo.getUrl(), capturedMediaInfo.getUrl());
    Assert.assertEquals(mediaInfo.getImages(), capturedMediaInfo.getImages());
    Assert.assertEquals(mediaInfo.getSubtitleInfo(), capturedMediaInfo.getSubtitleInfo());
    Assert.assertEquals(shouldLoop, argShouldLoop.getValue().booleanValue());
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:27,代碼來源:WebOSTVServiceTest.java

示例6: WebOSTVService

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
public WebOSTVService(ServiceDescription serviceDescription, ServiceConfig serviceConfig) {
    super(serviceDescription, serviceConfig);
    setServiceDescription(serviceDescription);

    pairingType = PairingType.FIRST_SCREEN;

    mAppToAppIdMappings = new ConcurrentHashMap<String, String>();
    mWebAppSessions = new ConcurrentHashMap<String, WebOSWebAppSession>();
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:10,代碼來源:WebOSTVService.java

示例7: disconnect

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Override
public void disconnect() {
    Log.d(Util.T, "attempting to disconnect to " + serviceDescription.getIpAddress());

    Util.runOnUI(new Runnable() {

        @Override
        public void run() {
            if (listener != null)
                listener.onDisconnect(WebOSTVService.this, null);
        }
    });

    if (socket != null) {
        socket.setListener(null);
        socket.disconnect();
        socket = null;
    }

    if (mAppToAppIdMappings != null)
        mAppToAppIdMappings.clear();

    if (mWebAppSessions != null) {
        Enumeration<WebOSWebAppSession> iterator = mWebAppSessions.elements();

        while (iterator.hasMoreElements()) {
            WebOSWebAppSession session = iterator.nextElement();
            session.disconnectFromWebApp();
        }

        mWebAppSessions.clear();
    }
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:34,代碼來源:WebOSTVService.java

示例8: launchWebApp

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Override
public void launchWebApp(final String webAppId, final JSONObject params, boolean relaunchIfRunning, final WebAppSession.LaunchListener listener) {
    if (webAppId == null) {
        Util.postError(listener, new ServiceCommandError(0, "Must pass a web App id", null));
        return;
    }

    if (relaunchIfRunning) {
        launchWebApp(webAppId, params, listener);
    } else {
        getLauncher().getRunningApp(new AppInfoListener() {

            @Override
            public void onError(ServiceCommandError error) {
                Util.postError(listener, error);
            }

            @Override
            public void onSuccess(AppInfo appInfo) {
                //  TODO: this will only work on pinned apps, currently
                if (appInfo.getId().indexOf(webAppId) != -1) {
                    LaunchSession launchSession = LaunchSession.launchSessionForAppId(webAppId);
                    launchSession.setSessionType(LaunchSessionType.WebApp);
                    launchSession.setService(WebOSTVService.this);
                    launchSession.setRawData(appInfo.getRawData());

                    WebOSWebAppSession webAppSession = webAppSessionForLaunchSession(launchSession);

                    Util.postSuccess(listener, webAppSession);
                } else {
                    launchWebApp(webAppId, params, listener);
                }
            }
        });
    }
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:37,代碼來源:WebOSTVService.java

示例9: testPlayMediaDeprecatedWithRequiredParametersOnTheLatestWebOS

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
@Test
public void testPlayMediaDeprecatedWithRequiredParametersOnTheLatestWebOS() {
    MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
    WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
    service.mWebAppSessions.put("MediaPlayer", webAppSession);

    MediaInfo mediaInfo = new MediaInfo.Builder("url", "mimetype").build();
    boolean shouldLoop = true;
    service.playMedia(mediaInfo.getUrl(), mediaInfo.getMimeType(), null, null, null,
            shouldLoop, listener);

    verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:14,代碼來源:WebOSTVServiceTest.java

示例10: callAndVerifyPlayMediaOnTheLatestWebOS

import com.connectsdk.service.sessions.WebOSWebAppSession; //導入依賴的package包/類
private void callAndVerifyPlayMediaOnTheLatestWebOS(final MediaInfo mediaInfo, boolean shouldLoop) {
    MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
    WebOSWebAppSession webAppSession = Mockito.mock(WebOSWebAppSession.class);
    service.mWebAppSessions.put("MediaPlayer", webAppSession);

    service.playMedia(mediaInfo, shouldLoop, listener);
    verifyPlayMediaOnTheLatestWebOS(mediaInfo, shouldLoop, listener, webAppSession);
}
 
開發者ID:david-fenton,項目名稱:Connect-SDK-Cordova-Plugin,代碼行數:9,代碼來源:WebOSTVServiceTest.java


注:本文中的com.connectsdk.service.sessions.WebOSWebAppSession類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。