def dev_event(dev, scanType, itemType, folder, user_data): global music_filter, pb if (scanType == MHDevScanCbType.MH_DEV_FIRST_FILE): if (itemType == MHItemType.MH_ITEM_MUSIC): _logging.output( 'First available music item was found, creating a playlist and beginning play' )
def run(): global _filter, playlist mh_misc_set_filter(MHMiscFilterType.MH_MISC_FILTER_MUSIC, b"mp3;wma;aac;wav;ogg;mp2", MHMiscFilterType.MH_MISC_FILTER_MOVIE, b"mp4;3gp;avi;mkv;mpg;mpeg;wmv;vob;flv;swf;mov;dat", MHMiscFilterType.MH_MISC_FILTER_PICTURE, b"jpg;png;bmp;jpeg;jfif;jpe;ico;gif;tiff;tif", None) _events_listener = MHEventsListener(event_cb(event_arrived), c_void_p(0)) _logging.resultA('Register Events Listener', mh_core_register_events_listener(byref(_events_listener))) _devices_listener = MHDevicesListener(device_cb(device_attached), c_void_p(0)) _logging.resultA( 'Register Devices Listener', mh_core_register_devices_listener(byref(_devices_listener))) mh_core_start() playlist = POINTER(c_void_p) _logging.output('Test is running') _filter = POINTER(c_void_p) index = int(input('1 means music,2 means movie:\n')) print('index', index) if index == 1: _filter = get_music_filter() elif index == 2: _filter = get_movie_filter() else: _filter = get_picture_filter() time.sleep(2) while True: _base = c_void_p() mh_object_get_properties(get_global_dev(), b"base", pointer(_base), c_void_p(0)) i = c_int(-1) pi = pointer(i) _items = POINTER(c_void_p) _items = mh_folder_get_children( _base, _filter, MHFolderPosition.FOLDER_BEGIN, pi, MHItemOrderType.MH_ITEM_ORDER_BY_DEFAULT) playlist = mh_folder_create_playlist(_base, _filter, False) _playlist_count = c_int(0) _pi_count = pointer(_playlist_count) mh_object_get_properties(playlist, b"count", _pi_count, c_int(0)) if _pi_count.contents.value == 0: print('playlist count=====0\n') else: mh_pb_play_by_list(get_pb(), playlist, 0) mh_item_foreach(_items, pi.contents, item_cb(item_function), None) time.sleep(2)
def run(): _devices_listener = MHDevicesListener(device_cb(local_attached), c_void_p(0)) _logging.resultA( 'Register Devices Listener', mh_core_register_devices_listener(byref(_devices_listener))) mh_core_start() _logging.output('Test is running') input('')
def device_attached(core, dev, event, user_data): global global_dev _detach_listener = MHDevDetachListener(detach_cb(device_detached), c_void_p(0)) _logging.attach('Device Event', event) _logging.resultA( 'Register Dev Listener', mh_dev_register_detach_listener(dev, byref(_detach_listener))) mh_object_ref(dev) _serial = c_char_p() _fsType = c_char_p() _entry = c_char_p() mh_object_get_properties(dev, b"serial", pointer(_serial), b'fs_type', pointer(_fsType), b'entry', pointer(_entry), c_void_p(0)) _logging.output('serial:\t' + _serial.value.decode()) _logging.output('fs type:\t' + _fsType.value.decode()) _logging.output('entry:\t' + _entry.value.decode()) _dev_events_listener = MHDevEventsListener(dev_events_cb(dev_event), c_void_p(0)) _logging.resultA( 'Register Dev Events Listener', mh_dev_register_events_listener(dev, byref(_dev_events_listener))) _logging.output('Starting Scan ...') mh_dev_start_scan(dev, MHDevScanType.SCAN_FOLDER) global_dev = dev
def run(): _events_listener = MHEventsListener(event_cb(event_arrived), c_void_p(0)) _logging.resultA('Register Events Listener', mh_core_register_events_listener(byref(_events_listener))) _devices_listener = MHDevicesListener(device_cb(device_attached), c_void_p(0)) _logging.resultA( 'Register Devices Listener', mh_core_register_devices_listener(byref(_devices_listener))) mh_core_start() _logging.output('Test is running') while True: time.sleep(2) mh_pb_next(get_pb())
def each_item_data(itemData, user_data): _logging.output('[' + str(cast(user_data, POINTER(py_object)).contents.value) + ']' + itemData.contents.name.decode('utf8')) cast(user_data, POINTER(py_object)).contents.value += 1 return False