Guest User

Tasker Mediabar Project

a guest
Sep 26th, 2026
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.79 KB | None | 0 0
  1. <TaskerData sr="" dvi="1" tv="6.7.3">
  2. <dmetric>1080.0,2400.0</dmetric>
  3. <Profile sr="prof401" ve="2">
  4. <cdate>1789166400000</cdate>
  5. <edate>1789166400000</edate>
  6. <flags>8</flags>
  7. <id>401</id>
  8. <mid0>501</mid0>
  9. <nme>MB V2 - Media State</nme>
  10. <Event sr="con0" ve="2">
  11. <code>2081</code>
  12. <pri>0</pri>
  13. <Bundle sr="arg0">
  14. <Vals sr="val">
  15. <net.dinglisch.android.tasker.RELEVANT_VARIABLES>&lt;StringArray sr=""/&gt;</net.dinglisch.android.tasker.RELEVANT_VARIABLES>
  16. <net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>
  17. </Vals>
  18. </Bundle>
  19. <Str sr="arg1" ve="3" />
  20. <Str sr="arg2" ve="3" />
  21. <Str sr="arg3" ve="3" />
  22. <Str sr="arg4" ve="3" />
  23. <Int sr="arg5" val="0" />
  24. </Event>
  25. </Profile>
  26. <Profile sr="prof402" ve="2">
  27. <cdate>1789166400000</cdate>
  28. <edate>1789166400000</edate>
  29. <flags>8</flags>
  30. <id>402</id>
  31. <mid0>502</mid0>
  32. <nme>MB V2 - Progress</nme>
  33. <Event sr="con0" ve="2">
  34. <code>2095</code>
  35. <pri>0</pri>
  36. <Bundle sr="arg0">
  37. <Vals sr="val">
  38. <net.dinglisch.android.tasker.RELEVANT_VARIABLES>&lt;StringArray sr=""/&gt;</net.dinglisch.android.tasker.RELEVANT_VARIABLES>
  39. <net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>[Ljava.lang.String;</net.dinglisch.android.tasker.RELEVANT_VARIABLES-type>
  40. </Vals>
  41. </Bundle>
  42. <Str sr="arg1" ve="3">500</Str>
  43. </Event>
  44. <State sr="con1" ve="2">
  45. <code>165</code>
  46. <ConditionList sr="if">
  47. <Condition sr="c0" ve="3">
  48. <lhs>%MBPlaying</lhs>
  49. <op>2</op>
  50. <rhs>true</rhs>
  51. </Condition>
  52. </ConditionList>
  53. </State>
  54. </Profile>
  55. <Profile sr="prof403" ve="2">
  56. <cdate>1789250000000</cdate>
  57. <edate>1789250000000</edate>
  58. <flags>8</flags>
  59. <id>403</id>
  60. <mid0>503</mid0>
  61. <nme>MB V2 - Live Slider</nme>
  62. <Event sr="con0" ve="2">
  63. <code>3050</code>
  64. <pri>0</pri>
  65. <Str sr="arg0" ve="3">%MBSeekLive</Str>
  66. <Str sr="arg1" ve="3" />
  67. <Int sr="arg2" val="0" />
  68. </Event>
  69. </Profile>
  70. <Project sr="proj0" ve="2">
  71. <cdate>1789166400000</cdate>
  72. <name>Media Bar - Tasker V2.7</name>
  73. <pids>401,402,403</pids>
  74. <tids>501,502,503</tids>
  75. </Project>
  76. <Task sr="task501">
  77. <cdate>1789166400000</cdate>
  78. <edate>1789166400000</edate>
  79. <id>501</id>
  80. <nme>MB V2 - Media State</nme>
  81. <pri>100</pri>
  82. <rty>1</rty>
  83. <Action sr="act0" ve="7">
  84. <code>474</code>
  85. <se>false</se>
  86. <Str sr="arg0" ve="3">import android.content.ComponentName;
  87. import android.media.MediaMetadata;
  88. import android.media.session.MediaController;
  89. import android.media.session.MediaSessionManager;
  90. import android.media.session.PlaybackState;
  91. import android.os.SystemClock;
  92.  
  93. String visualId = "media_bar_visual";
  94. String touchId = "media_bar_touch";
  95. String visualLayout = "{\"name\":\"Media Bar Visual\",\"root\":{\"type\":\"Box\",\"id\":\"root\",\"contentAlignment\":\"TopCenter\",\"modifiers\":[{\"type\":\"FillSize\"},{\"type\":\"Background\",\"color\":\"transparent\"}],\"children\":[{\"type\":\"ProgressBar\",\"id\":\"progress\",\"style\":\"Linear\",\"mode\":\"Determinate\",\"progress\":\"0\",\"minProgress\":\"0\",\"maxProgress\":\"1000\",\"color\":\"#FFFF6D00\",\"trackColor\":\"#22000000\",\"strokeCap\":\"Round\",\"animateChanges\":\"false\",\"modifiers\":[{\"type\":\"FillWidth\"},{\"type\":\"Size\",\"height\":\"4\"}]}]}}";
  96. String touchLayoutTemplate = "{\"name\":\"Media Bar Touch\",\"root\":{\"type\":\"Box\",\"id\":\"root\",\"contentAlignment\":\"TopCenter\",\"modifiers\":[{\"type\":\"FillSize\"},{\"type\":\"Background\",\"color\":\"transparent\"}],\"children\":[{\"type\":\"Slider\",\"id\":\"seek\",\"min\":\"0\",\"max\":\"1000\",\"steps\":\"0\",\"value\":\"__INITIAL__\",\"thumbColor\":\"#00000000\",\"activeTrackColor\":\"#00000000\",\"inactiveTrackColor\":\"#00000000\",\"activeTickColor\":\"#00000000\",\"inactiveTickColor\":\"#00000000\",\"sliderValueState\":{\"outputVariableBindings\":{\"value\":[\"MBSeekLive\"]}},\"modifiers\":[{\"type\":\"FillWidth\"},{\"type\":\"Size\",\"height\":\"28\"}]}]}}";
  97.  
  98. Object nls = tasker.getNotificationListener();
  99. if (nls == null) {
  100. tasker.setVariable("MBPlaying", "false");
  101. if (tasker.isSceneV2Active(visualId)) tasker.dismissSceneV2(visualId);
  102. if (tasker.isSceneV2Active(touchId)) tasker.dismissSceneV2(touchId);
  103. return null;
  104. }
  105.  
  106. MediaSessionManager msm = (MediaSessionManager) context.getSystemService("media_session");
  107. ComponentName listener = new ComponentName(context, nls.getClass());
  108. java.util.List controllers = msm.getActiveSessions(listener);
  109.  
  110. MediaController controller = null;
  111. PlaybackState chosenState = null;
  112. MediaMetadata chosenMetadata = null;
  113.  
  114. if (controllers != null) {
  115. for (int i = 0; i &lt; controllers.size(); i++) {
  116. MediaController c = (MediaController) controllers.get(i);
  117. PlaybackState s = c.getPlaybackState();
  118. MediaMetadata m = c.getMetadata();
  119. if (s == null || m == null) continue;
  120.  
  121. long duration = m.getLong(MediaMetadata.METADATA_KEY_DURATION);
  122. if (duration &lt;= 0) continue;
  123.  
  124. int st = s.getState();
  125.  
  126. if (st == PlaybackState.STATE_PLAYING ||
  127. st == PlaybackState.STATE_BUFFERING ||
  128. st == PlaybackState.STATE_CONNECTING ||
  129. st == PlaybackState.STATE_FAST_FORWARDING ||
  130. st == PlaybackState.STATE_REWINDING) {
  131. controller = c;
  132. chosenState = s;
  133. chosenMetadata = m;
  134. break;
  135. }
  136.  
  137. if (controller == null &amp;&amp; st == PlaybackState.STATE_PAUSED) {
  138. controller = c;
  139. chosenState = s;
  140. chosenMetadata = m;
  141. }
  142. }
  143. }
  144.  
  145. if (controller == null || chosenState == null || chosenMetadata == null) {
  146. tasker.setVariable("MBPlaying", "false");
  147. if (tasker.isSceneV2Active(visualId)) tasker.dismissSceneV2(visualId);
  148. if (tasker.isSceneV2Active(touchId)) tasker.dismissSceneV2(touchId);
  149. return null;
  150. }
  151.  
  152. boolean playing =
  153. chosenState.getState() == PlaybackState.STATE_PLAYING ||
  154. chosenState.getState() == PlaybackState.STATE_BUFFERING ||
  155. chosenState.getState() == PlaybackState.STATE_CONNECTING ||
  156. chosenState.getState() == PlaybackState.STATE_FAST_FORWARDING ||
  157. chosenState.getState() == PlaybackState.STATE_REWINDING;
  158.  
  159. tasker.setVariable("MBPlaying", playing ? "true" : "false");
  160.  
  161. /*
  162. * Detect a REAL media-item change, rather than treating every playback-state
  163. * callback as a new track. We store only a numeric hash in Tasker so metadata
  164. * punctuation cannot break Java-code substitution.
  165. */
  166. String mediaId = chosenMetadata.getString(MediaMetadata.METADATA_KEY_MEDIA_ID);
  167. String title = chosenMetadata.getString(MediaMetadata.METADATA_KEY_TITLE);
  168. String artist = chosenMetadata.getString(MediaMetadata.METADATA_KEY_ARTIST);
  169. String pkg = controller.getPackageName();
  170.  
  171. if (mediaId == null) mediaId = "";
  172. if (title == null) title = "";
  173. if (artist == null) artist = "";
  174. if (pkg == null) pkg = "";
  175.  
  176. long duration = chosenMetadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
  177. String fingerprint =
  178. pkg + "|" + mediaId + "|" + title + "|" + artist + "|" + duration;
  179. String newTrackHash = String.valueOf(fingerprint.hashCode());
  180. String oldTrackHash = "%MBTrackHash";
  181.  
  182. boolean trackChanged =
  183. oldTrackHash == null ||
  184. oldTrackHash.startsWith("%") ||
  185. !newTrackHash.equals(oldTrackHash);
  186.  
  187. if (trackChanged) {
  188. long now = SystemClock.elapsedRealtime();
  189.  
  190. tasker.setVariable("MBTrackHash", newTrackHash);
  191.  
  192. /*
  193. * Scene V2 can publish Slider binding values while it is being created
  194. * or recomposed. For the first 3 seconds of a new media item these are
  195. * NEVER allowed to seek the player.
  196. */
  197. tasker.setVariable(
  198. "MBSeekGuardUntil",
  199. String.valueOf(now + 3000)
  200. );
  201.  
  202. /* Reset user-gesture detection state. */
  203. tasker.setVariable("MBLastRaw", "");
  204. tasker.setVariable("MBLastRawMs", "0");
  205. tasker.setVariable("MBScrubActiveUntil", "0");
  206. tasker.setVariable("MBLastScrubMs", "0");
  207.  
  208. /*
  209. * Recreate only the invisible touch scene so its Slider starts at the
  210. * new track's own position rather than retaining the previous track's
  211. * last scrub position.
  212. */
  213. if (tasker.isSceneV2Active(touchId)) {
  214. tasker.dismissSceneV2(touchId);
  215. }
  216. }
  217.  
  218. long durationForPosition = duration;
  219. long position = chosenState.getPosition();
  220.  
  221. /*
  222. * IMPORTANT:
  223. * On a fresh track, some media apps report a stale lastPositionUpdateTime
  224. * while the new item is still buffering/initialising. Extrapolating here can
  225. * incorrectly make a brand-new track look several seconds old and, because
  226. * the Slider binding initialises from this value, can cause an unwanted seek.
  227. *
  228. * For the initial/media-state update use the player's reported position
  229. * directly. The normal 500 ms progress task handles smooth extrapolation later.
  230. */
  231. if (position &lt; 0) position = 0;
  232. if (position &gt; durationForPosition) position = durationForPosition;
  233.  
  234. int progress = (int)Math.round(position * 1000.0 / durationForPosition);
  235.  
  236. /*
  237. * Visible bar remains 91% wide, centred, matching V2.4.
  238. */
  239. if (!tasker.isSceneV2Active(visualId)) {
  240. tasker.showSceneV2(
  241. visualLayout,
  242. visualId,
  243. "Overlay",
  244. "50%",
  245. "0",
  246. "91%",
  247. "4",
  248. false,
  249. true,
  250. false
  251. );
  252. }
  253.  
  254. /*
  255. * Full-width touch surface.
  256. * The visible bar starts 4.5% in from each edge, so convert the current
  257. * media progress back into the Slider's full-screen coordinate system:
  258. *
  259. * rawSlider = 45 + progress * 0.91
  260. *
  261. * That means a binding initialization lands on the CURRENT media position
  262. * instead of accidentally seeking to the beginning.
  263. */
  264. if (!tasker.isSceneV2Active(touchId)) {
  265. int initialRaw = (int)Math.round(45.0 + (progress * 0.91));
  266. if (initialRaw &lt; 0) initialRaw = 0;
  267. if (initialRaw &gt; 1000) initialRaw = 1000;
  268.  
  269. String touchLayout = touchLayoutTemplate.replace(
  270. "__INITIAL__",
  271. String.valueOf(initialRaw)
  272. );
  273.  
  274. /*
  275. * Remember the Slider's initial value for diagnostics only. Actual seek
  276. * permission is controlled by the new-track guard plus genuine-motion
  277. * detection in MB V2 - Live Scrub.
  278. */
  279. tasker.setVariable("MBSeekInitRaw", String.valueOf(initialRaw));
  280.  
  281. tasker.showSceneV2(
  282. touchLayout,
  283. touchId,
  284. "Overlay",
  285. "50%",
  286. "0",
  287. "100%",
  288. "28",
  289. true,
  290. true,
  291. false
  292. );
  293. }
  294.  
  295. tasker.updateSceneV2(
  296. "progress",
  297. "color",
  298. playing ? "#FFFF6D00" : "#999E9E9E",
  299. visualId
  300. );
  301.  
  302. tasker.updateSceneV2(
  303. "progress",
  304. "progress",
  305. String.valueOf(progress),
  306. visualId
  307. );
  308.  
  309. return progress;</Str>
  310. <Str sr="arg1" ve="3">%mb_state_result</Str>
  311. <Int sr="arg2" val="0" />
  312. </Action>
  313. </Task>
  314. <Task sr="task502">
  315. <cdate>1789166400000</cdate>
  316. <edate>1789166400000</edate>
  317. <id>502</id>
  318. <nme>MB V2 - Progress</nme>
  319. <pri>101</pri>
  320. <rty>1</rty>
  321. <Action sr="act0" ve="7">
  322. <code>474</code>
  323. <se>false</se>
  324. <Str sr="arg0" ve="3">import android.content.ComponentName;
  325. import android.media.MediaMetadata;
  326. import android.media.session.MediaController;
  327. import android.media.session.MediaSessionManager;
  328. import android.media.session.PlaybackState;
  329. import android.os.SystemClock;
  330.  
  331. String visualId = "media_bar_visual";
  332. if (!tasker.isSceneV2Active(visualId)) return null;
  333.  
  334. /* Yield to live finger feedback while the Slider is moving. */
  335. String lastRaw = "%MBLastScrubMs";
  336. if (lastRaw != null &amp;&amp; !lastRaw.startsWith("%")) {
  337. try {
  338. long last = Long.parseLong(lastRaw);
  339. long now = SystemClock.elapsedRealtime();
  340. if (now - last &lt; 650) return null;
  341. } catch (Throwable ignored) {}
  342. }
  343.  
  344. Object nls = tasker.getNotificationListener();
  345. if (nls == null) return null;
  346.  
  347. MediaSessionManager msm = (MediaSessionManager) context.getSystemService("media_session");
  348. ComponentName listener = new ComponentName(context, nls.getClass());
  349. java.util.List controllers = msm.getActiveSessions(listener);
  350. if (controllers == null || controllers.isEmpty()) return null;
  351.  
  352. MediaController controller = null;
  353. PlaybackState state = null;
  354. MediaMetadata metadata = null;
  355.  
  356. for (int i = 0; i &lt; controllers.size(); i++) {
  357. MediaController c = (MediaController) controllers.get(i);
  358. PlaybackState s = c.getPlaybackState();
  359. MediaMetadata m = c.getMetadata();
  360.  
  361. if (s == null || m == null) continue;
  362. if (m.getLong(MediaMetadata.METADATA_KEY_DURATION) &lt;= 0) continue;
  363.  
  364. if (s.getState() == PlaybackState.STATE_PLAYING) {
  365. controller = c;
  366. state = s;
  367. metadata = m;
  368. break;
  369. }
  370. }
  371.  
  372. if (controller == null || state == null || metadata == null) return null;
  373.  
  374. long duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
  375. long position = state.getPosition();
  376. long elapsed = SystemClock.elapsedRealtime() - state.getLastPositionUpdateTime();
  377.  
  378. /*
  379. * Tasker refreshes this every 500 ms, so there is no reason to extrapolate
  380. * many seconds from a potentially stale MediaSession timestamp.
  381. */
  382. if (elapsed &lt; 0) elapsed = 0;
  383. if (elapsed &gt; 1500) elapsed = 1500;
  384.  
  385. position += (long)(elapsed * state.getPlaybackSpeed());
  386.  
  387. if (position &lt; 0) position = 0;
  388. if (position &gt; duration) position = duration;
  389.  
  390. int progress = (int)Math.round(position * 1000.0 / duration);
  391.  
  392. tasker.updateSceneV2(
  393. "progress",
  394. "progress",
  395. String.valueOf(progress),
  396. visualId
  397. );
  398.  
  399. return progress;</Str>
  400. <Str sr="arg1" ve="3">%mb_tick_result</Str>
  401. <Int sr="arg2" val="0" />
  402. </Action>
  403. </Task>
  404. <Task sr="task503">
  405. <cdate>1789166400000</cdate>
  406. <edate>1789166400000</edate>
  407. <id>503</id>
  408. <nme>MB V2 - Live Scrub</nme>
  409. <pri>110</pri>
  410. <rty>1</rty>
  411. <Action sr="act0" ve="7">
  412. <code>474</code>
  413. <se>false</se>
  414. <Str sr="arg0" ve="3">import android.content.ComponentName;
  415. import android.media.MediaMetadata;
  416. import android.media.session.MediaController;
  417. import android.media.session.MediaSessionManager;
  418. import android.media.session.PlaybackState;
  419. import android.os.SystemClock;
  420.  
  421. /*
  422. * Scene V2 Slider outputVariableBindings writes the Slider's CURRENT value
  423. * directly to %MBSeekLive while the thumb/finger moves.
  424. */
  425. String rawText = "%MBSeekLive";
  426. if (rawText == null || rawText.length() == 0 || rawText.startsWith("%")) return null;
  427.  
  428. double raw;
  429. try {
  430. raw = Double.parseDouble(rawText);
  431. } catch (Throwable e) {
  432. return null;
  433. }
  434.  
  435. if (raw &lt; 0) raw = 0;
  436. if (raw &gt; 1000) raw = 1000;
  437.  
  438. /*
  439. * IMPORTANT: %MBSeekLive is a Scene V2 output binding. Tasker can change it
  440. * for reasons other than a real finger drag (scene creation/recomposition).
  441. *
  442. * Therefore a single variable change is NEVER enough to seek media.
  443. * We first require a burst of changing values that looks like an actual drag.
  444. */
  445. long now = SystemClock.elapsedRealtime();
  446.  
  447. /* Hard block all bound Slider emissions just after a real track change. */
  448. String guardText = "%MBSeekGuardUntil";
  449. try {
  450. if (guardText != null &amp;&amp; !guardText.startsWith("%")) {
  451. long guardUntil = Long.parseLong(guardText);
  452. if (now &lt; guardUntil) {
  453. tasker.setVariable("MBLastRaw", String.valueOf(raw));
  454. tasker.setVariable("MBLastRawMs", String.valueOf(now));
  455. return null;
  456. }
  457. }
  458. } catch (Throwable ignored) {}
  459.  
  460. /* Read previous bound value and timing. */
  461. double lastRaw = raw;
  462. long lastRawMs = 0;
  463. long activeUntil = 0;
  464. boolean haveLast = false;
  465.  
  466. String lastRawText = "%MBLastRaw";
  467. String lastMsText = "%MBLastRawMs";
  468. String activeText = "%MBScrubActiveUntil";
  469.  
  470. try {
  471. if (lastRawText != null &amp;&amp; !lastRawText.startsWith("%") &amp;&amp;
  472. lastRawText.length() &gt; 0) {
  473. lastRaw = Double.parseDouble(lastRawText);
  474. haveLast = true;
  475. }
  476. } catch (Throwable ignored) {}
  477.  
  478. try {
  479. if (lastMsText != null &amp;&amp; !lastMsText.startsWith("%")) {
  480. lastRawMs = Long.parseLong(lastMsText);
  481. }
  482. } catch (Throwable ignored) {}
  483.  
  484. try {
  485. if (activeText != null &amp;&amp; !activeText.startsWith("%")) {
  486. activeUntil = Long.parseLong(activeText);
  487. }
  488. } catch (Throwable ignored) {}
  489.  
  490. double movement = Math.abs(raw - lastRaw);
  491. long interval = now - lastRawMs;
  492.  
  493. /*
  494. * A genuine drag produces multiple DIFFERENT Slider values rapidly.
  495. * An automatic initialization/recomposition normally produces a single value
  496. * or repeats the same value.
  497. */
  498. boolean movingNow =
  499. haveLast &amp;&amp;
  500. movement &gt;= 2.0 &amp;&amp;
  501. interval &gt;= 0 &amp;&amp;
  502. interval &lt;= 700;
  503.  
  504. boolean scrubActive = now &lt; activeUntil;
  505.  
  506. if (!scrubActive &amp;&amp; movingNow) {
  507. scrubActive = true;
  508. activeUntil = now + 900;
  509. tasker.setVariable(
  510. "MBScrubActiveUntil",
  511. String.valueOf(activeUntil)
  512. );
  513. } else if (scrubActive &amp;&amp; movement &gt;= 1.0) {
  514. activeUntil = now + 900;
  515. tasker.setVariable(
  516. "MBScrubActiveUntil",
  517. String.valueOf(activeUntil)
  518. );
  519. }
  520.  
  521. /* Always remember this sample for the next movement test. */
  522. tasker.setVariable("MBLastRaw", String.valueOf(raw));
  523. tasker.setVariable("MBLastRawMs", String.valueOf(now));
  524.  
  525. /*
  526. * First sample after idle only arms the detector. Seeking/live feedback starts
  527. * from the next moving sample, usually just a few pixels later.
  528. */
  529. if (!scrubActive) return null;
  530.  
  531. /*
  532. * The touch surface is 100% of the display, but the visible bar is only 91%
  533. * wide with a 4.5% inset on each side.
  534. *
  535. * Convert full-screen finger X into the visible media range:
  536. * 0..45 -&gt; 0%
  537. * 45..955 -&gt; 0..100%
  538. * 955..1000 -&gt; 100%
  539. */
  540. double mapped = (raw - 45.0) * 1000.0 / 910.0;
  541. if (mapped &lt; 0) mapped = 0;
  542. if (mapped &gt; 1000) mapped = 1000;
  543.  
  544. int progress = (int)Math.round(mapped);
  545.  
  546. /*
  547. * Mark this as live scrubbing so the normal playback tick temporarily yields.
  548. */
  549. tasker.setVariable(
  550. "MBLastScrubMs",
  551. String.valueOf(now)
  552. );
  553.  
  554. /*
  555. * VISUAL FEEDBACK FIRST: the bar moves to the current finger position before
  556. * waiting for the media app to process seekTo().
  557. */
  558. if (tasker.isSceneV2Active("media_bar_visual")) {
  559. tasker.updateSceneV2(
  560. "progress",
  561. "progress",
  562. String.valueOf(progress),
  563. "media_bar_visual"
  564. );
  565. }
  566.  
  567. Object nls = tasker.getNotificationListener();
  568. if (nls == null) return progress;
  569.  
  570. MediaSessionManager msm = (MediaSessionManager) context.getSystemService("media_session");
  571. ComponentName listener = new ComponentName(context, nls.getClass());
  572. java.util.List controllers = msm.getActiveSessions(listener);
  573. if (controllers == null || controllers.isEmpty()) return progress;
  574.  
  575. MediaController controller = null;
  576. MediaMetadata metadata = null;
  577.  
  578. for (int i = 0; i &lt; controllers.size(); i++) {
  579. MediaController c = (MediaController) controllers.get(i);
  580. PlaybackState s = c.getPlaybackState();
  581. MediaMetadata m = c.getMetadata();
  582.  
  583. if (s == null || m == null) continue;
  584.  
  585. long duration = m.getLong(MediaMetadata.METADATA_KEY_DURATION);
  586. if (duration &lt;= 0) continue;
  587.  
  588. int st = s.getState();
  589.  
  590. if (st == PlaybackState.STATE_PLAYING) {
  591. controller = c;
  592. metadata = m;
  593. break;
  594. }
  595.  
  596. if (controller == null &amp;&amp; st == PlaybackState.STATE_PAUSED) {
  597. controller = c;
  598. metadata = m;
  599. }
  600. }
  601.  
  602. if (controller == null || metadata == null) return progress;
  603.  
  604. long duration = metadata.getLong(MediaMetadata.METADATA_KEY_DURATION);
  605. long target = (long)Math.round(duration * mapped / 1000.0);
  606.  
  607. controller.getTransportControls().seekTo(target);
  608. return target;</Str>
  609. <Str sr="arg1" ve="3">%mb_live_scrub_result</Str>
  610. <Int sr="arg2" val="0" />
  611. </Action>
  612. </Task>
  613. </TaskerData>
Advertisement
Add Comment
Please, Sign In to add comment