Skip to content

Commit

Permalink
add HTTP endpoint: "/hide-player"
Browse files Browse the repository at this point in the history
  • Loading branch information
warren-bank committed Oct 15, 2021
1 parent f2b8750 commit 55a4bdd
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ __extended APIs:__
curl --silent -X GET \
"http://${airplay_ip}/show-player"
```
* hide the video player so it is no-longer the top-most foreground Activity:
```bash
# note: audio playback will continue in the background
curl --silent -X GET \
"http://${airplay_ip}/hide-player"
```
* show a Toast containing a custom message:
```bash
curl --silent -X POST \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ public interface Msg {

public static final int Msg_Show_Toast = 14;
public static final int Msg_Show_Player = 15;
public static final int Msg_Start_Activity = 16;
public static final int Msg_Hide_Player = 16;
public static final int Msg_Start_Activity = 17;

public static final int Msg_Runtime_Permissions_Granted = 17;
public static final int Msg_Runtime_Permissions_Granted = 18;
}

public interface Target {
Expand All @@ -207,6 +208,7 @@ public interface Target {

public static final String TOAST_SHOW = "/show-toast";
public static final String PLAYER_SHOW = "/show-player";
public static final String PLAYER_HIDE = "/hide-player";
public static final String ACTIVITY_START = "/start-activity";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,13 @@ else if (target.equals(Constant.Target.PLAYER_SHOW)) {

setCommonHeaders(httpResponse, HttpStatus.SC_OK);
}
else if (target.equals(Constant.Target.PLAYER_HIDE)) {
Message msg = Message.obtain();
msg.what = Constant.Msg.Msg_Hide_Player;
MainApp.broadcastMessage(msg);

setCommonHeaders(httpResponse, HttpStatus.SC_OK);
}
else if (
(entityContent != null) &&
target.equals(Constant.Target.ACTIVITY_START)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public void handleMessage(Message msg) {

switch (msg.what) {
case Constant.Msg.Msg_Photo :
case Constant.Msg.Msg_Hide_Player :
activity.finish();
break;
}
Expand Down
4 changes: 2 additions & 2 deletions android-studio-project/constants.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project.ext {
releaseVersionCode = Integer.parseInt("002002916", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '002.00.29-16API'
releaseVersionCode = Integer.parseInt("002003016", 10) //Integer.MAX_VALUE == 2147483647
releaseVersion = '002.00.30-16API'
javaVersion = JavaVersion.VERSION_1_8
minSdkVersion = 16
targetSdkVersion = 29
Expand Down
12 changes: 12 additions & 0 deletions tests/02. AirPlay sender.es5.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
var $toast_message = document.querySelector('textarea#toast_message')
var $show_toast = document.querySelector('button#show_toast')
var $show_player = document.querySelector('button#show_player')
var $hide_player = document.querySelector('button#hide_player')
var $intent_data = document.querySelector('textarea#intent_data')
var $load_video = document.querySelector('button#load_video')
var $send_intent = document.querySelector('button#send_intent')
Expand Down Expand Up @@ -716,6 +717,16 @@
send_message(path, data)
}

$hide_player.onclick = function(event) {
event.preventDefault()
event.stopPropagation()

var path = '/hide-player'
var data = null

send_message(path, data)
}

$load_video.onclick = function(event) {
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -1095,6 +1106,7 @@ <h3>User Interface:</h3>
<div>
<div><button id="show_toast">Show Toast</button></div>
<div><button id="show_player">Show Player</button></div>
<div><button id="hide_player">Hide Player</button></div>
</div>
</div>
<hr />
Expand Down
12 changes: 12 additions & 0 deletions tests/02. AirPlay sender.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@
const $toast_message = document.querySelector('textarea#toast_message')
const $show_toast = document.querySelector('button#show_toast')
const $show_player = document.querySelector('button#show_player')
const $hide_player = document.querySelector('button#hide_player')
const $intent_data = document.querySelector('textarea#intent_data')
const $load_video = document.querySelector('button#load_video')
const $send_intent = document.querySelector('button#send_intent')
Expand Down Expand Up @@ -933,6 +934,16 @@
send_message(path, data)
}

$hide_player.onclick = (event) => {
event.preventDefault()
event.stopPropagation()

const path = '/hide-player'
const data = null

send_message(path, data)
}

$load_video.onclick = (event) => {
event.preventDefault()
event.stopPropagation()
Expand Down Expand Up @@ -1311,6 +1322,7 @@ <h3>User Interface:</h3>
<div>
<div><button id="show_toast">Show Toast</button></div>
<div><button id="show_player">Show Player</button></div>
<div><button id="hide_player">Hide Player</button></div>
</div>
</div>
<hr />
Expand Down

0 comments on commit 55a4bdd

Please sign in to comment.